home *** CD-ROM | disk | FTP | other *** search
/ Night Owl 9 / Night Owl CD-ROM (NOPV9) (Night Owl Publisher) (1993).ISO / 015a / clock331.zip / CLOCK.DOC < prev    next >
Text File  |  1993-02-04  |  180KB  |  5,805 lines

  1.  
  2.  
  3.  
  4.  
  5.  
  6.  
  7.  
  8.  
  9.  
  10.  
  11.  
  12.  
  13.  
  14.  
  15.  
  16.  
  17.  
  18.  
  19.  
  20.  
  21.  
  22.  
  23.  
  24.  
  25.  
  26.                                         CLOCK
  27.  
  28.                                      Version 3.31
  29.  
  30.  
  31.  
  32.  
  33.                             CLOCK is a shareware program.
  34.                      See Appendix A for registration information.
  35.  
  36.  
  37.  
  38.  
  39.  
  40.  
  41.                        (c) Copyright 1991-1993 Ronald Q. Smith
  42.  
  43.  
  44.  
  45.  
  46.  
  47.  
  48.  
  49.  
  50.  
  51.  
  52.  
  53.  
  54.  
  55.  
  56.  
  57.  
  58.  
  59.  
  60.  
  61.  
  62.  
  63.  
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70.  
  71.  
  72.  
  73.  
  74.           CLOCK Version 3.31                               February 4, 1993
  75.  
  76.  
  77.                                        CONTENTS
  78.  
  79.  
  80.  
  81.           1  INTRODUCTION . . . . . . . . . . . . . . . . . . . . . . .   2
  82.  
  83.           2  CLOCK.SYS - Replacement Device Driver  . . . . . . . . . .   5
  84.                2.1  Unique Clock Hardware Support . . . . . . . . . . .   5
  85.                2.2  Installing CLOCK.SYS  . . . . . . . . . . . . . . .   6
  86.                2.3  Clock Type  . . . . . . . . . . . . . . . . . . . .  11
  87.                2.4  Examples  . . . . . . . . . . . . . . . . . . . . .  13
  88.                2.5  Future Enhancements . . . . . . . . . . . . . . . .  14
  89.  
  90.           3  CLK.EXE - Clock Control Program  . . . . . . . . . . . . .  15
  91.                3.1  CLK Command . . . . . . . . . . . . . . . . . . . .  15
  92.                3.2  Format of TZ= Function  . . . . . . . . . . . . . .  26
  93.                3.3  Using CLK . . . . . . . . . . . . . . . . . . . . .  30
  94.                3.4  Examples  . . . . . . . . . . . . . . . . . . . . .  33
  95.                3.5  Errors  . . . . . . . . . . . . . . . . . . . . . .  34
  96.                3.6  Future Enhancements . . . . . . . . . . . . . . . .  34
  97.  
  98.           4  CLKDEMO.EXE  . . . . . . . . . . . . . . . . . . . . . . .  36
  99.                4.1  CLKDEMO Command Line  . . . . . . . . . . . . . . .  36
  100.  
  101.           5  IOCTL - API TO CLOCK.SYS . . . . . . . . . . . . . . . . .  37
  102.                5.1  Data Structures . . . . . . . . . . . . . . . . . .  37
  103.                5.2  clksta  . . . . . . . . . . . . . . . . . . . . . .  41
  104.                5.3  setpw . . . . . . . . . . . . . . . . . . . . . . .  43
  105.                5.4  connec  . . . . . . . . . . . . . . . . . . . . . .  45
  106.                5.5  newpw . . . . . . . . . . . . . . . . . . . . . . .  47
  107.                5.6  rstrct  . . . . . . . . . . . . . . . . . . . . . .  49
  108.                5.7  stmode  . . . . . . . . . . . . . . . . . . . . . .  52
  109.                5.8  stzone  . . . . . . . . . . . . . . . . . . . . . .  54
  110.                5.9  tdisp . . . . . . . . . . . . . . . . . . . . . . .  58
  111.  
  112.           6  CLOCK.SYS - ASSEMBLY LANGUAGE API  . . . . . . . . . . . .  62
  113.                6.1  Opening the CLOCK$ Device . . . . . . . . . . . . .  62
  114.                6.2  Sending New Values to CLOCK.SYS . . . . . . . . . .  62
  115.                6.3  Getting Current Status of CLOCK.SYS . . . . . . . .  64
  116.  
  117.           APPENDIX A:  DEFINITION OF SHAREWARE  . . . . . . . . . . . .  65
  118.                                                                            
  119.  
  120.  
  121.  
  122.  
  123.  
  124.  
  125.  
  126.  
  127.                                           2
  128.  
  129.  
  130.  
  131.  
  132.  
  133.  
  134.  
  135.  
  136.  
  137.  
  138.  
  139.  
  140.           CLOCK Version 3.31                               February 4, 1993
  141.  
  142.  
  143.           APPENDIX B:  CLOCK TYPES  . . . . . . . . . . . . . . . . . .  68
  144.                B.1  Type 0 - PC/AT  . . . . . . . . . . . . . . . . . .  68
  145.                B.2  Type 1 - Zenith Z-18x portables, Supersport 20  . .  69
  146.                B.3  Type 2 - Various Zenith Data System PCs.  . . . . .  69
  147.                B.4  Type 3 - Memory-Mapped Clocks . . . . . . . . . . .  70
  148.                B.5  Type 4 - Direct Register I/O Bus Clock  . . . . . .  71
  149.                B.6  Type 5 - Mitsubishi 8088 PCs  . . . . . . . . . . .  73
  150.                B.7  Type 6 - Indirect Register I/O Bus Clock  . . . . .  74
  151.                B.8  Type 7 - Complex I/O Bus Clock  . . . . . . . . . .  75
  152.                B.9  Type 8 - Generic I/O Bus Clock  . . . . . . . . . .  77
  153.                B.10 Type 9 - Quadram I/O Bus Clock  . . . . . . . . . .  77
  154.                B.11 Type A - AT&T 6300, 6300 PLUS, 6300 WGS . . . . . .  78
  155.                B.12 Type B - Hyundai 8088 clock . . . . . . . . . . . .  79
  156.  
  157.           APPENDIX C:  REVISION HISTORY . . . . . . . . . . . . . . . .  81
  158.  
  159.  
  160.  
  161.  
  162.  
  163.  
  164.  
  165.  
  166.  
  167.  
  168.  
  169.  
  170.  
  171.  
  172.  
  173.  
  174.  
  175.  
  176.  
  177.  
  178.  
  179.  
  180.  
  181.  
  182.  
  183.  
  184.  
  185.  
  186.  
  187.  
  188.  
  189.  
  190.  
  191.  
  192.  
  193.                                           1
  194.  
  195.  
  196.  
  197.  
  198.  
  199.  
  200.  
  201.  
  202.  
  203.  
  204.  
  205.  
  206.           CLOCK Version 3.31                               February 4, 1993
  207.  
  208.  
  209.           1  INTRODUCTION
  210.  
  211.           CLOCK  consists of  two programs  that give you  complete control
  212.           over the operation of your calendar (battery-protected) clock and
  213.           your DOS/BIOS internal timer.   The normal DOS mode of  operation
  214.           is to  read the calendar clock  when you boot the  system and set
  215.           the internal timer.  Thereafter all read operations refer only to
  216.           the internal timer  while time setting  operations write to  both
  217.           clocks.  In levels of DOS prior to 3.3,  even time setting opera-
  218.           tions only  wrote to the  internal timer.   In order  to set  the
  219.           calendar clock you had to run the SETUP program.
  220.  
  221.           Some of the  drawbacks to the  standard DOS clock operation  that
  222.           the CLOCK programs address are:                                  
  223.  
  224.                ∙    There  is  no provision  to switch  time  zones without
  225.                     resetting the system time.
  226.  
  227.                ∙    DOS does not handle  automatic changes between daylight
  228.                     savings time and standard time.                        
  229.  
  230.                ∙    The DOS/BIOS internal timer  often drifts quite rapidly
  231.                     away  from the  time maintained  by  the more  accurate
  232.                     calendar clock.
  233.  
  234.                ∙    Even  the calendar  clock drifts  slowly away  from the
  235.                     accurate time.   DOS provides  no way to  automatically
  236.                     adjust for that drift.
  237.  
  238.                ∙    If your  battery is failing  or some other  hardware or
  239.                     software  problem messes up  the time in  your calendar
  240.                     clock, there is no way to detect that except by manual-
  241.                     ly displaying the time and checking it.                
  242.  
  243.                ∙    If you have to run a  program that occasionally changes
  244.                     the time incorrectly,  there is no way  to protect your
  245.                     clock  from those  changes.   You  can  also have  this
  246.                     problem  if you  are a  parent whose  children  set the
  247.                     clock when  you don't want them to, an instructor whose
  248.                     students  reset the time, or an expert young user whose
  249.                     parents mess up your clock.
  250.  
  251.  
  252.  
  253.  
  254.  
  255.  
  256.  
  257.  
  258.  
  259.                                           2
  260.  
  261.  
  262.  
  263.  
  264.  
  265.  
  266.  
  267.  
  268.  
  269.  
  270.  
  271.  
  272.           CLOCK Version 3.31                               February 4, 1993
  273.  
  274.  
  275.                ∙    If you need to experiment  with special times and dates
  276.                     but don't want  to have to reset your clock afterwards,
  277.                     DOS has no mechanism to help.  In order to test end-of-
  278.                     month processing for your application, you  have to set
  279.                     the  date and time,  run your  tests, and then  set the
  280.                     time and date back.
  281.  
  282.                ∙    The standard DOS and BIOS software on some PCs can miss
  283.                     the change  to a new  day when the  PC is left  on over
  284.                     midnight.
  285.  
  286.                ∙    Your clock  might not handle automatic changes to a new
  287.                     year or may not understand leap years.
  288.  
  289.                ∙    You may  have an older PC  from before the  PC/AT clock
  290.                     standardization and your vendor no  longer releases new
  291.                     versions  of DOS for that PC.  You are stuck on DOS 3.2
  292.                     or earlier or you have to give up your calendar clock. 
  293.  
  294.           If any of  those circumstances cause problems for  you, CLOCK can
  295.           help.   The two primary programs  are CLOCK.SYS and CLK.EXE.   In
  296.           addition, if you are a software developer, CLKDEMO is provided in
  297.           source code to show you how to program the extended  clock opera-
  298.           tions into your own applications.                                
  299.  
  300.  
  301.                CLOCK.SYS is a clock device driver (CLOCK$ device).  It
  302.                replaces the DOS internal clock driver.  CLOCK.SYS pro-
  303.                vides for  automatic time  zone  conversion.   It  also
  304.                allows you to periodically or continuously get the time
  305.                from the  calendar clock.   This can totally  eliminate
  306.                problems with  missing day changes and  realtime clocks     
  307.                that  are inaccurate.   CLOCK.SYS provides  support for
  308.                many types  of calendar  clocks including  many of  the
  309.                original add-in clocks of the  8088 era.  If your clock
  310.                is not currently supported, I want to hear from you.  I
  311.                will be happy to add it to the software.                    
  312.  
  313.                CLK.EXE  is  a program  that allows  you  to separately
  314.                control your DOS/BIOS  internal clock and  battery-pro-
  315.  
  316.  
  317.  
  318.  
  319.  
  320.  
  321.  
  322.  
  323.  
  324.  
  325.                                           3
  326.  
  327.  
  328.  
  329.  
  330.  
  331.  
  332.  
  333.  
  334.  
  335.  
  336.  
  337.  
  338.           CLOCK Version 3.31                               February 4, 1993
  339.  
  340.  
  341.                tected calendar clock.   Most importantly, CLK.EXE will
  342.                handle time zones and will automatically switch between
  343.                standard and  daylight savings time  for you.   It also     
  344.                supports automatic adjustment for calendar clock drift,
  345.                checks for  incorrect or  unlikely times,  and can  re-
  346.                strict time changes.
  347.  
  348.                CLKDEMO.EXE is a small part of CLK.EXE that is provided
  349.                in source  code (C language)  form so that you  can see     
  350.                how to add clock control to your own applications.
  351.  
  352.  
  353.  
  354.  
  355.  
  356.  
  357.  
  358.  
  359.  
  360.  
  361.  
  362.  
  363.  
  364.  
  365.  
  366.  
  367.  
  368.  
  369.  
  370.  
  371.  
  372.  
  373.  
  374.  
  375.  
  376.  
  377.  
  378.  
  379.  
  380.  
  381.  
  382.  
  383.  
  384.  
  385.  
  386.  
  387.  
  388.  
  389.  
  390.  
  391.                                           4
  392.  
  393.  
  394.  
  395.  
  396.  
  397.  
  398.  
  399.  
  400.  
  401.  
  402.  
  403.  
  404.           CLOCK Version 3.31                               February 4, 1993
  405.  
  406.  
  407.           2  CLOCK.SYS - Replacement Device Driver
  408.  
  409.           CLOCK.SYS is  a device driver  that replaces the  built-in CLOCK$
  410.           device driver in DOS levels 2.1  and above.  CLOCK.SYS adds  many
  411.           functions not provided in the standard DOS CLOCK$ device  driver.
  412.           You won't see mention of the DOS CLOCK$ device driver in your DOS
  413.           user's  guides.  You will  see a very small mention  of it in the
  414.           system's  programmers reference  manuals if  you are  an assembly
  415.           language developer.   It  is there and  DOS was  specifically de-
  416.           signed to let  you replace it  with one of  your own even if  the
  417.           manual doesn't tell you that.
  418.  
  419.  
  420.           2.1  Unique Clock Hardware Support
  421.                                                                            
  422.           CLOCK.SYS  was  originally written  especially  for  those people
  423.           whose  clocks  are not  supported  by new  levels of  DOS.   This
  424.           usually occurs  because your vendor stopped  providing new levels
  425.           of DOS  adapted for your computer model.   Before the days of the
  426.           PC/AT and standard clock interfaces, DOS was usually sold direct-
  427.           ly to  hardware vendors  who customized it  for their  system and
  428.           delivered it  with the system.   In  addition, many of  the early
  429.           clocks were provided by third-party, after-market vendors who had
  430.           no idea what system it would be used in.  Since those systems and
  431.           clocks have been  out of production for a long  time, most of the
  432.           vendors have stopped  providing upgrades.  Yet most  of those PCs
  433.           will happily run  DOS 3.3 or above and especially  DOS 5.0 except
  434.           that you have to give up your calendar clock.
  435.  
  436.           CLOCK.SYS supports a wide variety of different clock hardware and
  437.           BIOS interfaces.  As far as possible, CLOCK.SYS will automatical-
  438.           ly  determine what  clock  interface to  use.   If  the automatic
  439.           determination  does  not  work  for  your  system,  you may  tell
  440.           CLOCK.SYS specifically what interface type to use.   CLOCK.SYS is
  441.           also required  by anyone  who  wants to  use CLK  as it  provides
  442.           functions not  provided by the  normal DOS CLOCK$  device driver.
  443.           CLOCK.SYS  is fully compatible with the  DOS device driver on all
  444.           modern PCs and many older ones.
  445.                                                                            
  446.           If your PC clock is not currently supported but you would like to
  447.           remove the  restrictions on  what versions  of DOS  you can  use,
  448.  
  449.  
  450.  
  451.  
  452.  
  453.  
  454.  
  455.  
  456.  
  457.                                           5
  458.  
  459.  
  460.  
  461.  
  462.  
  463.  
  464.  
  465.  
  466.  
  467.  
  468.  
  469.  
  470.           CLOCK Version 3.31                               February 4, 1993
  471.  
  472.  
  473.           please contact me by  mail or on CompuServe.  I  will be happy to
  474.           add support for your clock.  I will need some  technical informa-
  475.           tion and help from you in getting it to work so I will give you a
  476.           $0  usage license for  your help.   Please see section  ? for the
  477.           current list of supported clocks and Appendix B for a description
  478.           of those clocks.
  479.  
  480.  
  481.           2.2  Installing CLOCK.SYS
  482.  
  483.  
  484.           To install the  device driver include the following  line in your
  485.           CONFIG.SYS file.
  486.  
  487.           Syntax    device=[d:][path\]clock.sys [type][,io_addr]
  488.                                                                            
  489.                                           or
  490.  
  491.                     device=[d:][path\]clock.sys 3[,segment[,write0,
  492.                          write1,read]]
  493.  
  494.                                           or
  495.  
  496.                     device=[d:][path\]clock.sys A[,base_year]
  497.  
  498.  
  499.           Parameters     d:
  500.                          Identifies the drive containing CLOCK.SYS.   If d:
  501.                          is not provided, the boot drive is assumed.
  502.  
  503.                     path\
  504.                          Specifies the directory  containing CLOCK.SYS.  If
  505.                          path\ is not given, the root directory is assumed.
  506.  
  507.                     CLOCK.SYS
  508.                          Is the name of the CLOCK.SYS file.  You may change
  509.                          the name  if you  wish, but you  must not  use the
  510.                          .COM or .EXE extensions.
  511.  
  512.                     type
  513.                          Is the kind of calendar clock on  your system.  If
  514.                          you do not provide type, CLOCK.SYS will probe your
  515.  
  516.  
  517.  
  518.  
  519.  
  520.  
  521.  
  522.  
  523.                                           6
  524.  
  525.  
  526.  
  527.  
  528.  
  529.  
  530.  
  531.  
  532.  
  533.  
  534.  
  535.  
  536.           CLOCK Version 3.31                               February 4, 1993
  537.  
  538.  
  539.                          system   to  determine   which  clock   you  have.
  540.                          CLOCK.SYS is  usually able  to detect the  type of
  541.                          calendar clock  without trouble.   It is possible,
  542.                          however, that you have some other hardware in your
  543.                          system  that could fool CLOCK.SYS.   For that rea-
  544.                          son, you might need to provide the type  of clock.
  545.                          See  section ? and Appendix B for more information
  546.                          about the clock types.
  547.  
  548.  
  549.                     io_addr
  550.                          Is the  I/O bus  address of  your clock  hardware.
  551.                          Some  of the  types of  clocks that  are supported
  552.                          were  set up at  a wide variety  of I/O addresses.
  553.                          CLOCK.SYS probes  all the  commonly  used I/O  ad-
  554.                          dresses  for these clocks.   However, you  or your
  555.                          vendor may have installed your clock at an address
  556.                          that CLOCK.SYS  doesn't know about.   By providing
  557.                          the  address, you  make it  much more  likely that
  558.                          CLOCK.SYS will correctly find your clock.  Even if
  559.                          you  don't know what type  of clock you have, pro-
  560.                          viding the I/O address may be enough for CLOCK.SYS
  561.                          to determine which one it is.  io_addr is current-
  562.                          ly  used with clock  types 4, 6,  7, 8,  9, and B.
  563.                          Normally this is 240, 2C0, or 340 for types  4, 6,
  564.                          and 7.  It is 210 or 310 for type 9.  And it is E0
  565.                          for type B.  All numbers are in hex.  For example,
  566.                          an AST Research clock might be:
  567.                                                                            
  568.                          device=[d:][path\]clock.sys 4,2C0
  569.  
  570.                          If  you do  not  specify the  "io_addr", CLOCK.SYS
  571.                          will try to determine the correct address by prob-
  572.                          ing.
  573.  
  574.  
  575.                          If you are sure that you have an I/O clock but you
  576.                          are not sure  which one it is, specify  type 8 and
  577.                          supply the io_addr  if possible.  Type  8 does not
  578.                          represent a specific clock.  Rather it attempts to
  579.                          determine whether your clock is a type 4, 6, 7, 9,
  580.                          or  B using a  sequence of tests  similar to those
  581.  
  582.  
  583.  
  584.  
  585.  
  586.  
  587.  
  588.  
  589.                                           7
  590.  
  591.  
  592.  
  593.  
  594.  
  595.  
  596.  
  597.  
  598.  
  599.  
  600.  
  601.  
  602.           CLOCK Version 3.31                               February 4, 1993
  603.  
  604.  
  605.                          used by  some of the  I/O clock vendors  to figure
  606.                          out what kind of clock you have.                  
  607.  
  608.                     If  you have  a memory  mapped clock,  you may  use the
  609.                     second format  to specify the addresses to be used.  If
  610.                     you don't know the addresses, CLOCK.SYS will attempt to
  611.                     determine them by probing.
  612.  
  613.                     segment                                                
  614.                          Is  the base  address  used to  access the  clock.
  615.                          Usually your documentation  will give the  segment
  616.                          address as four hex  digits such as FE00 or  F000.
  617.                          Some addresses may be less than four digits (e.g.,
  618.                          70).   Other  documentation may show  addresses in
  619.                          the  form aaaa:bbbb.   In  this  case the  segment
  620.                          address is  the aaaa value.   Sometimes these  ad-
  621.                          dresses are  written as 0xaaaa,  aaaah, aaaaH,  or
  622.                          0Xaaaa.  In all of these forms there is a 2- to 4-
  623.                          digit hex number that is the segment address.
  624.  
  625.                     write0                                                 
  626.                          Is the offset used to write  0 bits.  It must also
  627.                          be a hex address  and may be 0, F002,  or anything
  628.                          else the vendor chose.  If the addresses are given
  629.                          in the aaaa:bbbb form, use  the bbbb.  With  these
  630.                          clocks, you  read and  write the clock  by reading
  631.                          the  memory addresses.   For example,  reading ad-
  632.                          dress segment:write0 results in writing a zero bit
  633.                          to  the clock.  Writing  an appropriate length se-
  634.                          quence of zero and one bits sets the clock.
  635.  
  636.                     write1
  637.                          Is the offset used to write 1 bits.
  638.  
  639.  
  640.                     read
  641.                          Is the offset used to read bits.
  642.  
  643.                          If  your documentation  gives the  segment address
  644.                          but isn't  clear about  the offsets, just  specify
  645.                          the  segment address  and CLOCK.SYS  will try  all
  646.                          offset combinations that it knows about.
  647.  
  648.  
  649.  
  650.  
  651.  
  652.  
  653.  
  654.  
  655.                                           8
  656.  
  657.  
  658.  
  659.  
  660.  
  661.  
  662.  
  663.  
  664.  
  665.  
  666.  
  667.  
  668.           CLOCK Version 3.31                               February 4, 1993
  669.  
  670.  
  671.                          If you specify one of the offsets, you must speci-
  672.                          fy them all.
  673.  
  674.                     The third format is used with the AT&T 6300 clocks.
  675.  
  676.                     base_year
  677.                          Is used for the AT&T 6300 clocks  (type=A).  Dates
  678.                          prior to that year or more than 7 years after that
  679.                          year will  not be handled  correctly.  If  no base
  680.                          year is specified,  1992 will be used.   Dates be-
  681.                          tween the start of  the base year  and the end  of
  682.                          the seventh year later are handled (e.g., 1992-1-1
  683.                          until 1999-12-31).
  684.  
  685.           Notes     DOS interfaces                    
  686.                     --------------
  687.                     All DOS  DATE and  TIME commands and  all DOS  date and
  688.                     time system calls will  operate with no apparent change
  689.                     to you  or any program.   Unless you  have used  CLK to
  690.                     change the time handling, your  clocks are handled just
  691.                     as DOS would handle them.
  692.  
  693.                     Dates and leap years                    
  694.                     --------------------
  695.                     CLOCK.SYS supports all valid DOS dates from 1980-1-1 to
  696.                     2079-12-31.  It supports  dates to 2099-12-31 for  many
  697.                     of the clocks.  CLOCK.SYS also handles year changes and
  698.                     leap years automatically for  clock types that don't do
  699.                     it themselves.           
  700.  
  701.                     Time zones and daylight savings time                    
  702.                     ------------------------------------
  703.                     CLOCK.SYS in conjunction  with CLK.EXE provides support
  704.                     for multiple  time zones and  automatic conversion  be-
  705.                     tween daylight  savings time and  standard time at  the
  706.                     appropriate  times  of  the  year.   For  this  reason,
  707.                     CLOCK.SYS may  be of  great  use to  you even  if  your
  708.                     version of DOS already supports your clock correctly.
  709.  
  710.                     Clock synchronization                    
  711.                     ---------------------
  712.                     Normally,  CLOCK.SYS  operates identically  to  the DOS
  713.                     CLOCK$ device  driver.  At  boot it sets the  DOS clock
  714.                     from the calendar clock.  Any time  you change the date
  715.                     or time it writes to both clocks.
  716.  
  717.                                           9
  718.  
  719.  
  720.  
  721.  
  722.  
  723.  
  724.  
  725.  
  726.  
  727.  
  728.  
  729.  
  730.           CLOCK Version 3.31                               February 4, 1993
  731.  
  732.  
  733.                     With CLK.EXE  you have several  other options.   If you
  734.                     have  specified a  time zone  and offset  with CLK.EXE,
  735.                     CLOCK.SYS will adjust  all times read from  and written
  736.                     to the calendar clock by the time zone offset.  You can
  737.                     also set  it to read the calendar clock rather than the
  738.                     DOS  clock for  some  or all  time  requests to  ensure
  739.                     continued synchronization of  the two clocks.   You can
  740.                     also totally separate the  two clocks so that  DOS time
  741.                     and  date functions  only read  and write  the DOS/BIOS
  742.                     internal clock.
  743.  
  744.                     Time setting limits                    
  745.                     -------------------
  746.                     CLK.EXE  can tell CLOCK.SYS to apply limits to the time
  747.                     changes that  it will  accept  or stop  accepting  time
  748.                     changes at all.  For example, you can tell CLOCK.SYS to
  749.                     accept no  changes that would  set the clock  backward.
  750.                     You can also inhibit all changes.
  751.  
  752.                     Password Protection                    
  753.                     -------------------
  754.                     CLK.EXE can  establish  a password  to  control  future
  755.                     changes to the time zone, connection, and  time setting
  756.                     limits.   Once  the password  is  set, all  attempts to
  757.                     change those values  will simply be ignored  unless the
  758.                     correct password  is  supplied.   You  may  change  the
  759.                     daylight versus standard time  flag and the  continuous
  760.                     time display without knowing the password.             
  761.  
  762.                     Continuous Time Display                    
  763.                     -----------------------
  764.                     CLK.EXE can tell CLOCK.SYS to display the time continu-
  765.                     ously at any position on your screen.   You specify the
  766.                     cursor coordinates, display  attributes, and 12-hour or
  767.                     24-hour  mode  and  CLOCK.SYS will  update  the display
  768.                     every second.                                          
  769.  
  770.                     Saving Settings Across Boots                    
  771.                     ----------------------------
  772.                     With  CLK.EXE  you  can  save  the   current  state  of
  773.                     CLOCK.SYS at  any time  in a form  that can be  used on
  774.                     your next boot.  You can set up your time zone, setting
  775.                     limits, connection mode, continuous display, and  pass-
  776.                     word  and then save  a new version  of CLOCK.SYS.  This
  777.                     new  version  will  automatically  start  running  with
  778.  
  779.  
  780.  
  781.  
  782.  
  783.                                           10
  784.  
  785.  
  786.  
  787.  
  788.  
  789.  
  790.  
  791.  
  792.  
  793.  
  794.  
  795.  
  796.           CLOCK Version 3.31                               February 4, 1993
  797.  
  798.  
  799.                     without having to scan for your clock type and with all
  800.                     your standard state automatically in effect.           
  801.  
  802.  
  803.           2.3  Clock Type
  804.  
  805.           There are almost as many  different implementations of PC  clocks
  806.           as there are different types of PCs.  Until the PC/AT came along,
  807.           there was no  standard for battery-protected clocks,  and each PC
  808.           and add-in vendor was likely to implement them differently.  With
  809.           the PC/AT a standard and documented interface for such clocks was
  810.           provided.   Since  that time,  most PCs  have followed  the PC/AT
  811.           standard.  It  is earlier  PCs, especially 8088  PCs, that  don't
  812.           follow the standard.  Since these are early PCs, there  is also a
  813.           high probability that the vendor is no longer  providing modified
  814.           versions of  DOS with  built-in support for  their clocks.   Most
  815.           add-in clock vendors never did provide a modified DOS and you had
  816.           to  manage your  clock with  utility programs.   This  leaves you
  817.           faced with  the choice between  staying with an early  version of
  818.           DOS or giving up your clock.
  819.  
  820.  
  821.           CLOCK.SYS is  intended to free  you from  those limitations.   It
  822.           will  work with all  versions of DOS  from 2.10  through 5.00 and
  823.           undoubtedly beyond.   It also attempts to automatically determine
  824.           what kind of clock  you have and install the  correct support for
  825.           it.  However, there are often enough differences between PCs that
  826.           the automatic  determination may  not find  anything or  may even
  827.           make the wrong choice.   To give you  more control of the  situa-
  828.           tion, you may specify the  clock interface by giving an interface
  829.           number.
  830.  
  831.           It will not  always be  easy to decide  what interface number  to
  832.           use.   You will at least  need some technical information  on how
  833.           your clock  works or on the  BIOS calls used to  control the bat-
  834.           tery-protected clock.  If you find a description below that seems
  835.           to match, give  it a try.  The most that  should go wrong is that
  836.           your time and  date will be set incorrectly, but then they proba-
  837.           bly weren't working anyhow.
  838.  
  839.  
  840.           If you aren't sure what interface to  use or if you are sure that
  841.           your clock is not supported, LET ME  KNOW.  I WOULD LIKE TO HELP.
  842.  
  843.  
  844.  
  845.  
  846.  
  847.  
  848.  
  849.                                           11
  850.  
  851.  
  852.  
  853.  
  854.  
  855.  
  856.  
  857.  
  858.  
  859.  
  860.  
  861.  
  862.           CLOCK Version 3.31                               February 4, 1993
  863.  
  864.  
  865.           You can help me make CLOCK.SYS better for everyone.  I would even
  866.           like  to hear  from you if  CLOCK.SYS did  work for  you and your
  867.           clock isn't  currently listed.   I would like  to be able  to add
  868.           your PC manufacturer  and model number  to the supported  list so
  869.           others know what to use.  If CLOCK.SYS did not work for you, I am
  870.           interested in  making the changes so  that it does work.   If you
  871.           can provide me with the  necessary technical information, I  will
  872.           make the changes.
  873.  
  874.  
  875.           Usually,  a technical  reference  manual with  hardware and  BIOS
  876.           interfaces is the best source.  Even  if you don't have one, your
  877.           original  hardware  vendor  may be  willing  to  send  you enough
  878.           information to  allow you  to  program the  clock.   If all  else
  879.           fails,  we may even be able to use  an old copy of DOS or a clock
  880.           setting utility to figure out how  it works.  Before we do  that,
  881.           check your license to be sure that it  is not forbidden to disas-
  882.           semble the software to see how the clock works.  
  883.  
  884.           The following table  shows the systems that  have been determined
  885.           to work  with existing  clock types.   If your  system is  in the
  886.           list, try  the clock type indicated.  If not, look through Appen-
  887.           dix  B which tells you about the  characteristics of each type of
  888.           clock and see if anything seems to match your system type.
  889.  
  890.  
  891.  
  892.  
  893.  
  894.  
  895.  
  896.  
  897.  
  898.  
  899.  
  900.  
  901.  
  902.  
  903.  
  904.  
  905.  
  906.  
  907.  
  908.  
  909.  
  910.  
  911.  
  912.  
  913.  
  914.  
  915.                                           12
  916.  
  917.  
  918.  
  919.  
  920.  
  921.  
  922.  
  923.  
  924.  
  925.  
  926.  
  927.  
  928.           CLOCK Version 3.31                               February 4, 1993
  929.  
  930.  
  931.  
  932.                            SYSTEM                 CLOCK TYPE
  933.  
  934.  
  935.                    Amstrad PC1521DD        0 (May have to specify
  936.                                            type to be recog-
  937.                                            nized.)
  938.  
  939.                    AST Research            8 (4, 6, or 7)  See
  940.                      Six-Pack              discussion above and
  941.                      I/O Plus              in Appendix B.                  
  942.                      etc.
  943.  
  944.                    AT&T 6300               A
  945.  
  946.                    Hyundai 8088            B
  947.  
  948.                    IBM PC/AT               0
  949.                    and most PCs since
  950.                    then.
  951.  
  952.                    Leading Edge Model D    5
  953.  
  954.                    Mitsubishi 8088         5
  955.  
  956.                    Quadram Corp.           9
  957.                      QuadCard
  958.                      QuadCard II
  959.                      QuadCard 512+
  960.  
  961.                    SMT No-Slot Clock       3
  962.  
  963.                    Sperry PC-1             5
  964.  
  965.                    Sperry PC/HT            5
  966.  
  967.                    Tandy 1200HD            4
  968.  
  969.                    Vendex Turbo-888-XT     4
  970.  
  971.                    Zenith Supersport 20    1
  972.                    Zenith Z-18x            1
  973.  
  974.  
  975.  
  976.  
  977.  
  978.  
  979.  
  980.  
  981.                                           13
  982.  
  983.  
  984.  
  985.  
  986.  
  987.  
  988.  
  989.  
  990.  
  991.  
  992.  
  993.  
  994.           CLOCK Version 3.31                               February 4, 1993
  995.  
  996.  
  997.           2.4  Examples
  998.  
  999.           For almost everyone, the only format you ever need to use is:
  1000.  
  1001.                device=[d:][path\]clock.sys
  1002.  
  1003.           If CLOCK.SYS is in  the root directory of your boot  device, this
  1004.           is:
  1005.                device=clock.sys
  1006.  
  1007.  
  1008.           CLOCK.SYS will  quite happily load  into the upper  memory blocks
  1009.           (UMBs) provided by DOS 5.0 and by  other software.  With DOS 5.0,
  1010.           you might use:
  1011.                devicehigh=clock.sys
  1012.  
  1013.           With some  memory managers you can even load CLOCK.SYS into upper
  1014.           memory blocks on earlier levels of DOS.   See your manual for the
  1015.           commands to use.  Some of these  memory managers will create UMBs
  1016.           on 8088  and 80286 systems.   CLOCK.SYS  loads and  runs high  on
  1017.           those systems as well.
  1018.  
  1019.           With a memory mapped clock that uses an address combination  that
  1020.           CLOCK.SYS doesn't search automatically  and with CLOCK.SYS stored
  1021.           in the C:\UTILITY directory, you might use:
  1022.                device=c:\utility\clock.sys 3,ffff,f000,f004,f008
  1023.           Please note that the memory addresses chosen for this example are
  1024.           not likely to match those of your clock and you should substitute
  1025.           the addresses appropriate to your clock.
  1026.  
  1027.  
  1028.           If you have an  I/O clock with the same interface  as the Quadram
  1029.           Corp. clock but a different I/O address, you might use:
  1030.                device=clock.sys 9,3fc
  1031.           if your I/O base address were 3fc.
  1032.  
  1033.  
  1034.           If you have one of the AT&T 6300 system types and you occasional-
  1035.           ly need to set your clock prior to 1992-1-1, you might use:
  1036.                device=clock.sys a,1988
  1037.  
  1038.           2.5  Future Enhancements
  1039.  
  1040.  
  1041.  
  1042.  
  1043.  
  1044.  
  1045.  
  1046.  
  1047.                                           14
  1048.  
  1049.  
  1050.  
  1051.  
  1052.  
  1053.  
  1054.  
  1055.  
  1056.  
  1057.  
  1058.  
  1059.  
  1060.           CLOCK Version 3.31                               February 4, 1993
  1061.  
  1062.  
  1063.           Of course,  I hope  to add  more clocks as  people ask  for them.
  1064.           Those old PCs are still good for a lot of what we do even if they
  1065.           are sometimes relegated to a secondary status.                   
  1066.  
  1067.           There are no other outstanding enhancements currently planned for
  1068.           CLOCK.SYS.
  1069.  
  1070.  
  1071.  
  1072.  
  1073.  
  1074.  
  1075.  
  1076.  
  1077.  
  1078.  
  1079.  
  1080.  
  1081.  
  1082.  
  1083.  
  1084.  
  1085.  
  1086.  
  1087.  
  1088.  
  1089.  
  1090.  
  1091.  
  1092.  
  1093.  
  1094.  
  1095.  
  1096.  
  1097.  
  1098.  
  1099.  
  1100.  
  1101.  
  1102.  
  1103.  
  1104.  
  1105.  
  1106.  
  1107.  
  1108.  
  1109.  
  1110.  
  1111.  
  1112.  
  1113.                                           15
  1114.  
  1115.  
  1116.  
  1117.  
  1118.  
  1119.  
  1120.  
  1121.  
  1122.  
  1123.  
  1124.  
  1125.  
  1126.           CLOCK Version 3.31                               February 4, 1993
  1127.  
  1128.  
  1129.           3  CLK.EXE - Clock Control Program
  1130.  
  1131.           CLK gives you complete control over the operation of the calendar
  1132.           clock  and DOS/BIOS  clock.  You  can operate  them separately or
  1133.           together.  You  can establish time  zones, daylight savings  time
  1134.           rules, automatic adjustment, synchronization rules, and more.
  1135.  
  1136.  
  1137.           3.1  CLK Command
  1138.  
  1139.  
  1140.           Syntax    clk [function] [function ...] [/I[file]] [/?]
  1141.  
  1142.                               or in full form
  1143.  
  1144.                     clk [A=±sss.cc] [C=A|D|R|W] [D=[N][x,y,a[,12|,24]]     
  1145.                          [L=...] [R=A|B-hh:mm:ss|F+hh:mm:ss|N|R]
  1146.                          [S=C|D]  [TZ=...]  [W=-back,+forward]   [/I[file]]
  1147.                          [/P[N]] [/S[file]] [/?] [T?] [TZ=:?]
  1148.  
  1149.           Parameters     function
  1150.                          There are  many functions  that may  be used  with
  1151.                          CLK.EXE and  they are  discussed in  the following
  1152.                          paragraphs.  You  may use any number  of functions
  1153.                          on a  single command line  and they  will be  pro-
  1154.                          cessed  in  the order  in  which  you enter  them.
  1155.                          However, if any error is discovered  in any of the
  1156.                          functions, none of them are processed.  Thus,     
  1157.                               clk c=r tz=:est
  1158.                          is the same as the two command lines:
  1159.                               clk c=r
  1160.                               clk tz=:est
  1161.                          except that an error in either of the functions in
  1162.                          the first  example cause  the whole command  to be
  1163.                          ignored.
  1164.  
  1165.                          The case (upper  or lower) of any  of the function
  1166.                          names, options, or  values is  ignored except  for
  1167.                          the TZ function's  time zone names.   Even  there,
  1168.                          the case is not used.   It is simply preserved for
  1169.                          later display.
  1170.  
  1171.  
  1172.  
  1173.  
  1174.  
  1175.  
  1176.  
  1177.  
  1178.  
  1179.                                           16
  1180.  
  1181.  
  1182.  
  1183.  
  1184.  
  1185.  
  1186.  
  1187.  
  1188.  
  1189.  
  1190.  
  1191.  
  1192.           CLOCK Version 3.31                               February 4, 1993
  1193.  
  1194.  
  1195.                     none
  1196.                          If no function or option is provided, CLK displays
  1197.                          the current  state of operation  of CLOCK.SYS  and
  1198.                          the current time from both the  calendar clock and
  1199.                          the DOS/BIOS clock.
  1200.  
  1201.                          If you have used CLK to set a time  zone (TZ func-
  1202.                          tion), the current time zone name and offset value
  1203.                          are  displayed.     These  values  are  saved   in
  1204.                          CLOCK.SYS so that they may  be used for time func-
  1205.                          tions.
  1206.  
  1207.                          The connection state of the clocks (C function) is
  1208.                          displayed  as is the current restrictions (R func-
  1209.                          tion) on clock changes.
  1210.  
  1211.  
  1212.                          All  uses  of CLK  (except errors  and /?)  end by
  1213.                          displaying the  same information.  You always know
  1214.                          the state of your two clocks after execution.
  1215.  
  1216.                     A=±sss.cc                                              
  1217.                          The Adjust function is used to set a daily adjust-
  1218.                          ment factor in seconds and 100ths of seconds.
  1219.  
  1220.                          This function assumes that you have some knowledge
  1221.                          of the  rate at  which your calendar  clock drifts
  1222.                          with respect to "real" time.   Presumably you have
  1223.                          periodically set your  clock using a  program that
  1224.                          calls the Naval Observatory or NIST and  noted the
  1225.                          difference  over  time.   Some such  programs will
  1226.                          help you to calculate the drift rate.  You can get
  1227.                          a very good adjustment from a decent quartz watch.
  1228.  
  1229.  
  1230.                          The value may be a positive or  negative number in
  1231.                          the range -326.99  to +326.99 seconds per  day but
  1232.                          reasonable values are likely to be a fraction of a
  1233.                          second.
  1234.  
  1235.                          The first time  you use A=, your clock  is not ad-
  1236.                          justed.  The value of  A and the current time  are
  1237.                          saved in  a file  for later  use.   Later you  can
  1238.  
  1239.  
  1240.  
  1241.  
  1242.  
  1243.  
  1244.  
  1245.                                           17
  1246.  
  1247.  
  1248.  
  1249.  
  1250.  
  1251.  
  1252.  
  1253.  
  1254.  
  1255.  
  1256.  
  1257.  
  1258.           CLOCK Version 3.31                               February 4, 1993
  1259.  
  1260.  
  1261.                          choose to run CLK with the /I option to invoke the
  1262.                          file.  The elapsed  time since the last adjustment
  1263.                          (or the time you last changed A) in days and frac-
  1264.                          tions is multiplied by A to  calculate any adjust-
  1265.                          ment that needs to be applied.  Only whole seconds
  1266.                          of adjustment are applied.
  1267.  
  1268.                          The A=  function only sets the  adjustment factor.
  1269.                          The  actual adjustment  is carried  out by  the L=
  1270.                          function.   You don't have  to enter the  L= func-
  1271.                          tion.  CLK will do that for you the first time you
  1272.                          use  A= and will  keep it up  to date  as it later
  1273.                          makes adjustments.
  1274.  
  1275.                          NOTE:   Do not use the  A= function with  the AT&T
  1276.                          6300 clocks (Type A)  or the Quadram clocks  (Type
  1277.                          9).  They  only permit the time  to be set to  the
  1278.                          nearest minute.
  1279.  
  1280.                     C=A
  1281.                          Connects  the two clocks for  All operations.  All
  1282.                          read operations go directly to the calendar clock.
  1283.                          The  calendard clock is read, the time is adjusted
  1284.                          for any time zone offset, and the adjusted time is
  1285.                          written to the DOS clock and returned to the call-
  1286.                          er.   With this function, your  calendar clock es-
  1287.                          sentially  becomes the only  clock.   However, the
  1288.                          DOS clock is set each time so that any application
  1289.                          reading the clock directly  (without going through
  1290.                          DOS) sees the same time  that DOS reports.  It  is
  1291.                          unwise  to use this function if your clock is slow
  1292.                          (some I/O clocks and some memory-mapped clocks) or
  1293.                          if it  only increments  in units of  seconds (most
  1294.                          clocks).  Any time zone offset is applied to reads
  1295.                          and writes.
  1296.  
  1297.  
  1298.  
  1299.  
  1300.  
  1301.  
  1302.  
  1303.  
  1304.  
  1305.  
  1306.  
  1307.  
  1308.  
  1309.  
  1310.  
  1311.                                           18
  1312.  
  1313.  
  1314.  
  1315.  
  1316.  
  1317.  
  1318.  
  1319.  
  1320.  
  1321.  
  1322.  
  1323.  
  1324.           CLOCK Version 3.31                               February 4, 1993
  1325.  
  1326.  
  1327.                     C=D
  1328.                          Disconnects  the two  clocks.   Any change  of the
  1329.                          date  and  time will  affect  the DOS  clock only.
  1330.                          Reads  also use the DOS clock only.  This function
  1331.                          allows you  to perform any  operation on  the time
  1332.                          without affecting  your  calendar clock.    It  is
  1333.                          useful for dealing  with ill-behaved programs that
  1334.                          need to change the  time and for testing  programs
  1335.                          at different dates  and times.  You  can later use
  1336.                          the C=R,  C=A, or other  functions to re-establish
  1337.                          the  value  in your  DOS  clock from  the calendar
  1338.                          clock.
  1339.  
  1340.                     C=R
  1341.                          Connects the  two clocks for writing  and periodic
  1342.                          Reading.    This function  may be  used  when your
  1343.                          clocks drift  slowly with respect  to each  other.
  1344.                          If  the time has not  been read for  about 10 sec-
  1345.                          onds, the calendar clock will be read, adjusted by
  1346.                          the offset if any,  and the adjusted time  written
  1347.                          to the DOS clock and returned to the caller.  This
  1348.                          periodic Read  assures you  that the  clocks never
  1349.                          get  very  far out  of  synchronization  with each
  1350.                          other.   Some  calendar  clocks take  a relatively
  1351.                          long  time to read  and most don't  have 100ths of
  1352.                          seconds.  By only  reading the calendar clock when
  1353.                          no other time request has  occurred in the last 10
  1354.                          seconds, we  minimize both  the  overhead and  any
  1355.                          visibility of time jumps.
  1356.  
  1357.                     C=W
  1358.                          Connects the two clocks for Writing.  This is  the
  1359.                          default  mode of  operation and  is the  same mode
  1360.                          that the DOS CLOCK$  device driver supports as its
  1361.                          only mode.   Reading the time is served by the DOS
  1362.                          clock.  Writing  the time sets both clocks.   If a
  1363.                          time  zone offset  has previously  been specified,
  1364.                          all  writes to the clock  are adjusted so that the
  1365.                          calendar  clock remains  on the  base  time.   For
  1366.                          example, if the  calendar clock is set to  UTC and
  1367.                          you specify that you want to use CST which has  an
  1368.  
  1369.  
  1370.  
  1371.  
  1372.  
  1373.  
  1374.  
  1375.  
  1376.  
  1377.                                           19
  1378.  
  1379.  
  1380.  
  1381.  
  1382.  
  1383.  
  1384.  
  1385.  
  1386.  
  1387.  
  1388.  
  1389.  
  1390.           CLOCK Version 3.31                               February 4, 1993
  1391.  
  1392.  
  1393.                          offset of 6 hours from UTC, all writes of the time
  1394.                          will have 6  hours added to them before writing to
  1395.                          the calendar  clock.  Thus  the DOS clock  and the
  1396.                          calendar clock remain at a constant time offset.
  1397.  
  1398.                     D=N
  1399.                          The  D= function  controls a continuous  time dis-
  1400.                          play.  D=N turns off the continuous display.
  1401.  
  1402.  
  1403.                     D=x,y,a[,12|,24]
  1404.                          Starts a continuous time  display at cursor  posi-
  1405.                          tion x,y with display  attribute a.  Cursor  posi-
  1406.                          tion 0,0 is  the upper left corner of  the screen.
  1407.                          The typical screen format runs from 0,0 to  79,24.
  1408.                          The display  attribute is  a two-digit  hex number
  1409.                          that  gives the background  and foreground colors.
  1410.                          The high-order digit is the background color (0 to
  1411.                          7 usually)  and the  low-order digit is  the fore-
  1412.                          ground or character  color (0 to F).   The default
  1413.                          display is a 24-hour  clock in the form  HH:MM:SS.
  1414.                          If you add  the ",12", the display will  use a 12-
  1415.                          hour clock.  No AM or PM indication is given.
  1416.  
  1417.                          D=72,24,79,12 will place the display at the  right
  1418.                          edge of the last line  of most screens.  The  text
  1419.                          will be in bright  blue on a white  background and
  1420.                          the hours will run from 12 through 11.
  1421.  
  1422.  
  1423.                     L=YYYY-MM-DD,hh:mm:ss,±sss.cc                          
  1424.                          The L= function is not intended to be used on  the
  1425.                          command line,  but will be accepted if you provide
  1426.                          it.   The L= function  is normally created  by CLK
  1427.                          and  saved in the  CLK.INI file  for later  use in
  1428.                          processing adjustments.  The date  and time of the
  1429.                          last adjustment (or the most recent  time you gave
  1430.                          an A= function  on the command line)  are given by
  1431.                          the YYYY-MM-DD,hh:mm:ss.   Any non-digit except  a
  1432.                          space may separate  the sub-fields.  The  date and
  1433.                          time must be  followed by a comma and  any adjust-
  1434.                          ment  remainder.  The  adjustment remainder  is in
  1435.  
  1436.  
  1437.  
  1438.  
  1439.  
  1440.  
  1441.  
  1442.  
  1443.                                           20
  1444.  
  1445.  
  1446.  
  1447.  
  1448.  
  1449.  
  1450.  
  1451.  
  1452.  
  1453.  
  1454.  
  1455.  
  1456.           CLOCK Version 3.31                               February 4, 1993
  1457.  
  1458.  
  1459.                          the same form as the value for the A= function but
  1460.                          will usually be a fraction of a second.  It is the
  1461.                          adjustment that  was left  over the  last time  an
  1462.                          adjustment  was  actually  made  since  only whole
  1463.                          seconds of changes are made to the clock.
  1464.  
  1465.                          The  L= function triggers an adjustment if needed.
  1466.                          Generally,  it will  follow the  A= function  that
  1467.                          sets the  adjustment factor.  Both  of these func-
  1468.                          tions normally appear in the CLK.INI file.
  1469.  
  1470.                          The  L= function may also be  used by itself to do
  1471.                          simple  arithmetic on the  clocks.  Use  it on the
  1472.                          command line with any earlier date and time and an
  1473.                          adjustment of  the number of seconds  (positive or
  1474.                          negative) that you want added  to the clock.   The
  1475.                          change will  be made and the  last adjustment time
  1476.                          set to the current time.  For example, 
  1477.                               clk l=1990-1-1,0:0:0,-4
  1478.                          will subtract 4 seconds from the clocks.
  1479.  
  1480.  
  1481.                     R=A
  1482.                          The R= function sets restrictions on time changes.
  1483.                          R=A inhibits All time changes.  When this  mode is
  1484.                          set, all  attempts to change the  time are ignored
  1485.                          by CLOCK.SYS.  This  includes time changes attemp-
  1486.                          ted by CLK including time adjustments.  See R=N.
  1487.  
  1488.  
  1489.                     R=B-hh:mm:ss
  1490.                          This function limits the amount of Backward change
  1491.                          of the time.   Any change of more  than the speci-
  1492.                          fied time is  ignored.  The "-" is optional as are
  1493.                          the offset fields.                                
  1494.                               clk r=b
  1495.                          inhibits all backward changes.
  1496.                               CLK R=B::2
  1497.                          only  allows  backward changes  of two  seconds or
  1498.                          less This might permit CLK to perform  adjustments
  1499.                          but effectively stop other backward changes.
  1500.  
  1501.  
  1502.  
  1503.  
  1504.  
  1505.  
  1506.  
  1507.  
  1508.  
  1509.                                           21
  1510.  
  1511.  
  1512.  
  1513.  
  1514.  
  1515.  
  1516.  
  1517.  
  1518.  
  1519.  
  1520.  
  1521.  
  1522.           CLOCK Version 3.31                               February 4, 1993
  1523.  
  1524.  
  1525.                     R=F+hh:mm:ss
  1526.                          This function limits the amount  of Forward change
  1527.                          of the time.   Any change of more than  the speci-
  1528.                          fied time is ignored.  The "+" is optional  as are
  1529.                          the offset fields.
  1530.                               CLK R=F+1:00:02
  1531.                          limits  forward changes to  1 hour and  2 seconds.
  1532.                          The R=B and R=F  limits do not apply to  the auto-
  1533.                          matic  conversions between  standard and  daylight
  1534.                          savings time  as these don't  actually change  the
  1535.                          time.  The R=B and R=F functions are also indepen-
  1536.                          dent of the R=A function.
  1537.  
  1538.                     R=N
  1539.                          This function reverses the R=A function and inhib-
  1540.                          its No clock changes.   The R=A is independent  of
  1541.                          the R=B and R=F.  You can set backward and forward
  1542.                          limits with  R=B and R=F.   Later you  can inhibit
  1543.                          all changes with R=A.  When you do R=N, the previ-
  1544.                          ously set R=B and R=F limits again have an effect.
  1545.  
  1546.  
  1547.                     R=R
  1548.                          This function Resets the limits established by R=B
  1549.                          and R=F.  No limits are in effect  after executing
  1550.                          this function.  It has no effect on the R=A mode.
  1551.  
  1552.                     S=C
  1553.  
  1554.                          Sets both  clocks  to the  current  time from  the
  1555.                          calendar  clock.   You can  use this  even  if the
  1556.                          clocks  are  disconnected to  make  the  DOS clock
  1557.                          equal to the calendar clock.  The time zone offset
  1558.                          is  set to 00:00:00 and the  time zone name is set
  1559.                          to UTC to indicate that both clocks are set to the
  1560.                          base time.
  1561.  
  1562.  
  1563.  
  1564.  
  1565.  
  1566.  
  1567.  
  1568.  
  1569.  
  1570.  
  1571.  
  1572.  
  1573.  
  1574.  
  1575.                                           22
  1576.  
  1577.  
  1578.  
  1579.  
  1580.  
  1581.  
  1582.  
  1583.  
  1584.  
  1585.  
  1586.  
  1587.  
  1588.           CLOCK Version 3.31                               February 4, 1993
  1589.  
  1590.  
  1591.                     S=D
  1592.                          Sets both clocks  to the current time from the DOS
  1593.                          clock.  The value from the DOS clock is written to
  1594.                          the calendar clock.   The time zone offset  is set
  1595.                          to 00:00:00 and  the zone name  is not changed  to
  1596.                          indicate that both  clocks are set  to your  local
  1597.                          time.
  1598.  
  1599.                     TZ=...                                                 
  1600.                          Sets the DOS clock to the correct local time based
  1601.                          on the value of the  expression following the TZ=.
  1602.                          This  expression  conforms  exactly to  the  POSIX
  1603.                          1003.1  standard for time zone  handling.  CLK as-
  1604.                          sumes that the  calendar clock currently  contains
  1605.                          UTC (also  known as  GMT, Greenwich,  ZULU, and  Z
  1606.                          time).    UTC  ("Universal  Time,  Coordinated" is
  1607.                          usually spoken as "coordinated universal time") is
  1608.                          the name of the  international standard time  that
  1609.                          is provided  by WWV, WWVH, the  Naval Observatory,
  1610.                          and NIST as well as many other services around the
  1611.                          world.   Most  Unix(r)  systems  also  support  TZ
  1612.                          although many  only  partially support  the  POSIX
  1613.                          standard.   See  the notes  later  for a  complete
  1614.                          description of the TZ= function.
  1615.  
  1616.                          You  can  put  the  CLK  TZ=...  command  in  your
  1617.                          AUTOEXEC.BAT file.  You should put it prior to any
  1618.                          other statements that  may create or  update files
  1619.                          or  you run the risk  of having confusing times in
  1620.                          your  file directory  (MAKE  could get  especially
  1621.                          confused.).  If  you provide a TZ=  function, your
  1622.                          system  will automatically  adjust to  the correct
  1623.                          time zone every time  you boot.  Note that  no at-
  1624.                          tempt is made to change between daylight and stan-
  1625.                          dard time  except  when  you  execute  CLK  TZ=...
  1626.                          Adjusting on  the  fly is  very  dangerous.   Many
  1627.                          programs  can produce  incorrect  results or  even
  1628.                          corrupt your data if time takes a big step forward.
  1629.                          
  1630. --------------------
  1631. Unix is a registered trademark of Unix Systems Laboratories.
  1632.  
  1633.  
  1634.  
  1635.  
  1636.  
  1637.  
  1638.  
  1639.  
  1640.  
  1641.                                           23
  1642.  
  1643.  
  1644.  
  1645.  
  1646.  
  1647.  
  1648.  
  1649.  
  1650.  
  1651.  
  1652.  
  1653.  
  1654.           CLOCK Version 3.31                               February 4, 1993
  1655.  
  1656.  
  1657.                          and are  even more  likely to do  so if  time runs
  1658.                          backward.   See section ?  for a discussion of the
  1659.                          TZ= format.
  1660.  
  1661.  
  1662.                     W=-back,+forward
  1663.                          The W= function is used to establish Warning  lim-
  1664.                          its on  the time.   Each time  the W= function  is
  1665.                          processed  (usually  from the  CLK.INI  file), the
  1666.                          current time and  the previous time are  compared.
  1667.  
  1668.                          If the current time is outside the  -back,+forward
  1669.                          range around  the previous time, a warning message
  1670.                          is displayed  requiring you to  press a key.   The
  1671.                          program will  also exit with  an ERRORLEVEL  of 1.
  1672.                          The full form of the W= function is:
  1673.                          W=N-days/hh:mm:ss,+days/hh:mm:ss,                 
  1674.                               YYYY-MM-DD,hh:mm:ss
  1675.  
  1676.                          The  days sub-field is a value from 0 to 250 days.
  1677.                          The  days sub-field  combined with  the time  sub-
  1678.                          fields gives the maximum interval around  the pre-
  1679.                          vious  time  within which  the  current time  must
  1680.                          fall.   The previous date and time follow the sec-
  1681.                          ond comma.  For example,
  1682.                               clk w=-0/00:00:02,+91
  1683.                          will  establish a  range of  minus two  seconds to
  1684.                          plus 91 days.   The first time you  use this func-
  1685.                          tion nothing will happen except  that CLK will add
  1686.                          the current date and time to the command and store
  1687.                          it in the CLK.INI file.  The next time  you use if
  1688.                          from  the  CLK.INI file  with CLK /I,  the current
  1689.                          date and  time will  be compared  to the  previous
  1690.                          date and time  and the range.  If the current time
  1691.                          is outside  the range, a message  is displayed and
  1692.                          CLK pauses.
  1693.  
  1694.                          The sign characters and all of  the sub-fields are
  1695.                          optional.  Missing sub-fields are treated as zero.
  1696.                          The particular separators are not important except
  1697.                          for  the commas.   Any non-digit character  can be
  1698.                          used  for the other separators.  The time and date
  1699.                          fields are  appended to  the function by  CLK when
  1700.  
  1701.  
  1702.  
  1703.  
  1704.  
  1705.  
  1706.  
  1707.                                           24
  1708.  
  1709.  
  1710.  
  1711.  
  1712.  
  1713.  
  1714.  
  1715.  
  1716.  
  1717.  
  1718.  
  1719.  
  1720.           CLOCK Version 3.31                               February 4, 1993
  1721.  
  1722.  
  1723.                          the CLK.INI  file is written and  are the previous
  1724.                          time to which the next comparison will be made.  A
  1725.                          typical  function might  be  W=,31.   This command
  1726.                          will  display a  warning whenever  time  has moved
  1727.                          backwards at  all or  has moved  forwards by  more
  1728.                          than 31 days since the  last time you used CLK /I.
  1729.                          If you use CLK /I (see below) in your AUTOEXEC.BAT
  1730.                          file,  this is  very likely  to detect  a miss-set
  1731.                          clock or bad clock battery.  Yet it won't generate
  1732.                          a  message on  every boot.  You will  only get  an
  1733.                          "unnecessary" message if  it has been more  than a
  1734.                          month since you last used the PC.
  1735.  
  1736.                          If  the "N" character (or "n") appears immediately
  1737.                          after the "=", CLK does not pause and wait for you
  1738.                          to press a key after printing the warning message.
  1739.                          The "N" allows you  to use CLK in a .BAT  file and
  1740.                          check for the warning  with the IF ERRORLEVEL com-
  1741.                          mand.
  1742.  
  1743.                     /I                                                     
  1744.                     or
  1745.                     /Ifile
  1746.                          The I  option tells CLK  to read the  CLK.INI file
  1747.                          (or "file" if that  is given) for additional func-
  1748.                          tions.  These functions are usually A=, L=, and W=
  1749.                          functions that were previously written to the file
  1750.                          by CLK.  You  may add any other functions  (but no
  1751.                          options) to the file and they will be processed as
  1752.                          if you had entered them at the  end of the command
  1753.                          line.   If you  don't specify "file"  or you don't
  1754.                          give a path  as part of "file",  CLK will use  the
  1755.                          directory which  contains CLK.EXE.   Thus  the de-
  1756.                          fault  is to  use  CLK.INI in  the directory  that
  1757.                          contains CLK.EXE.  
  1758.  
  1759.                          If  you enter  an A=,  L=, or  W= function  or CLK
  1760.                          finds them in  the file, the file  will be updated
  1761.                          with the  new values  for  the current  time  when
  1762.                          appropriate.   If an  adjustment is  made, the  L=
  1763.                          function  will reflect  the date  and time  of the
  1764.                          latest adjustment.   CLK  will update or  create a
  1765.  
  1766.  
  1767.  
  1768.  
  1769.  
  1770.  
  1771.  
  1772.  
  1773.                                           25
  1774.  
  1775.  
  1776.  
  1777.  
  1778.  
  1779.  
  1780.  
  1781.  
  1782.  
  1783.  
  1784.  
  1785.  
  1786.           CLOCK Version 3.31                               February 4, 1993
  1787.  
  1788.  
  1789.                          CLK.INI file even  if you don't use  the /I option
  1790.                          if  you use  the A=,  L=, or  W= functions  on the
  1791.                          command line.
  1792.  
  1793.  
  1794.                          It is very useful to store your standard TZ=,  C=,
  1795.                          and  R= functions in the CLK.INI  file.  Then your
  1796.                          AUTOEXEC.BAT  file  can simply  contain  a CLK  /I
  1797.                          command  to set  your clocks  into their  standard
  1798.                          modes, adjust  the time,  and check for  bad clock
  1799.                          values.   You can also  reestablish your  standard
  1800.                          modes after  changes with the same command entered
  1801.                          from the DOS prompt or a .BAT file.
  1802.  
  1803.                     /P
  1804.                     or                                                     
  1805.                     /PN
  1806.                          Controls the  use of password  protection of  mode
  1807.                          changes.  When you use /P, CLK will ask  you for a
  1808.                          new password.  It will  then ask you to repeat the
  1809.                          password to ensure that you entered what you want.
  1810.                          It does  not display the password as you enter it.
  1811.  
  1812.                          The password is then passed to CLOCK.SYS and pass-
  1813.                          word  protection is enabled.   On future  calls to
  1814.                          CLOCK.SYS, you will be  asked for the password  if
  1815.                          protection is enabled.  You may use /PN to disable
  1816.                          password protection, but you  will have to provide
  1817.                          the  current password to do so.   If used with the
  1818.                          /S feature, the password protection will remain in
  1819.                          effect even across reboots.  /P should be the last
  1820.                          field on a CLK command line.
  1821.  
  1822.                     /S
  1823.                     or                                                     
  1824.                     /Sfile
  1825.                          Saves the current copy of  CLOCK.SYS as it resides
  1826.                          in memory.   If you  do not specify the  file, the
  1827.                          memory version is written to file CLOCK.NEW in the
  1828.                          same directory  that contains CLK.EXE.   While you
  1829.                          may  directly overwrite  the  file CLOCK.SYS,  you
  1830.                          should be very careful  doing so as whatever  your
  1831.  
  1832.  
  1833.  
  1834.  
  1835.  
  1836.  
  1837.  
  1838.  
  1839.                                           26
  1840.  
  1841.  
  1842.  
  1843.  
  1844.  
  1845.  
  1846.  
  1847.  
  1848.  
  1849.  
  1850.  
  1851.  
  1852.           CLOCK Version 3.31                               February 4, 1993
  1853.  
  1854.  
  1855.                          current state is will take effect on the next boot.
  1856.  
  1857.                          PLEASE  MAKE  A  BACKUP  COPY  of  your   original
  1858.                          CLOCK.SYS before replacing it  with a saved  file.
  1859.                          The  saved file  does not do  any probing  at boot
  1860.                          time as  it already knows exactly  what your clock
  1861.                          is.   It does not  need any parameters  on the de-
  1862.                          vice= line in CONFIG.SYS.
  1863.  
  1864.  
  1865.                          The /S  option may be extremely  useful for anyone
  1866.                          with multiple  similar systems  to maintain.   You
  1867.                          can set  up all of  your options  once on one  ma-
  1868.                          chine, save those with the /S option, and then use
  1869.                          the saved  file to  directly  install on  all  the
  1870.                          other machines.   If you use  password protection,
  1871.                          no  one  can change  the other  systems  except by
  1872.                          modifying  CONFIG.SYS  to  remove  the loading  of
  1873.                          CLOCK.SYS.
  1874.  
  1875.                          You  will still need  to run CLK  as part of every
  1876.                          boot operation (e.g.,  in AUTOEXEC.BAT) to  do any
  1877.                          automatic adjustment (A= and L=  functions), check
  1878.                          for clock failures (W= function), and check to see
  1879.                          whether the  clock should use the standard or day-
  1880.                          light offsets (TZ= function).  These functions are
  1881.                          not processed  automatically by  CLOCK.SYS because
  1882.                          they would increase the size  of the device driver
  1883.                          to an unacceptable limit.
  1884.  
  1885.                     /?
  1886.                          "/?"  or any error  will cause CLK  to display the
  1887.                          usage format.   If you have an error in any field,
  1888.                          CLK first displays that field.
  1889.  
  1890.  
  1891.                     T?
  1892.                          "T?" or any error in a TZ= function will cause CLK
  1893.                          to display the format of the TZ function.
  1894.  
  1895.  
  1896.  
  1897.  
  1898.  
  1899.  
  1900.  
  1901.  
  1902.  
  1903.  
  1904.  
  1905.                                           27
  1906.  
  1907.  
  1908.  
  1909.  
  1910.  
  1911.  
  1912.  
  1913.  
  1914.  
  1915.  
  1916.  
  1917.  
  1918.           CLOCK Version 3.31                               February 4, 1993
  1919.  
  1920.  
  1921.                     TZ=:?
  1922.                          "TZ=:?" or any error in a TZ= function that refers
  1923.                          to a pre-defined  time zone causes CLK  to display
  1924.                          all the  current pre-defined  time zone names  and
  1925.                          their associated values.
  1926.  
  1927.  
  1928.           3.2  Format of TZ= Function
  1929.  
  1930.  
  1931.           The format of TZ=... can get quite complicated as the standard is
  1932.           trying to  deal with  all time  zones and  daylight savings  time
  1933.           rules around the world.  The full format is:
  1934.  
  1935.                TZ=:zone
  1936.                or                                                          
  1937.                TZ=STD[offset][DAY[offset][,start[/time],end[/time]]]
  1938.  
  1939.           Parameters     zone
  1940.                          The form TZ=:zone  is the one you  are most likely
  1941.                          to need.   CLK knows the offsets and daylight sav-
  1942.                          ings time rules  for most of the U.S.  and all you
  1943.                          have to supply is the name of your time zone.  The
  1944.                          time zones currently known to CLK are:
  1945.                          EST  Eastern U.S. with automatic daylight
  1946.                          CST  Central U.S. with automatic daylight
  1947.                          MST  Mountain U.S. with automatic daylight
  1948.                          PST  Pacific U.S. with automatic daylight         
  1949.                          HST  Hawaiian with no daylight savings time
  1950.  
  1951.                          You can use CLK TZ=:? to display  the list of pre-
  1952.                          defined zone names and their values.
  1953.  
  1954.                          If you would like your favorite time added, please
  1955.                          send me the names, offset  from UTC, and any  day-
  1956.                          light savings time  rules that are  different from
  1957.                          the  U.S.  NOTE:  The names can be composed of any
  1958.                          characters except digits,  plus, minus, and comma.
  1959.                          They can be  up to  32 characters long.   Case  is
  1960.                          preserved in the  names only for later  display by
  1961.                          CLK.  You can call your zone MyZone.
  1962.  
  1963.  
  1964.  
  1965.  
  1966.  
  1967.  
  1968.  
  1969.  
  1970.  
  1971.                                           28
  1972.  
  1973.  
  1974.  
  1975.  
  1976.  
  1977.  
  1978.  
  1979.  
  1980.  
  1981.  
  1982.  
  1983.  
  1984.           CLOCK Version 3.31                               February 4, 1993
  1985.  
  1986.  
  1987.                          Case is not important  in matching the zone names.
  1988.                          tz=:cst is  the equivalent of TZ=:CST.   Both will
  1989.                          find the definition of CST.
  1990.  
  1991.                                   
  1992.                     You don't have to wait for me to modify CLK in order to
  1993.                     use your local rules or just try something out.  That's
  1994.                     what the long form is for.
  1995.  
  1996.                     STD                                                    
  1997.                          is any time  zone name for standard  time that you
  1998.                          want to use.  See the note above for the rules.
  1999.  
  2000.  
  2001.                     offset
  2002.                          is  the difference between your local time and UTC
  2003.                          and is expressed as hh[:mm[:ss]]  with an optional
  2004.                          leading + or -.  Offsets for times  West of Green-
  2005.                          wich are positive and those  East are negative.  A
  2006.                          24-hour  clock is  used  with  times running  from
  2007.                          00:00:00  to 23:59:59.    Mountain  Standard  time
  2008.                          would be expressed as:                            
  2009.                               TZ=MST+07:00:00
  2010.                                    or
  2011.                               TZ=MST7
  2012.                          and that's  what you would use if you live in Ari-
  2013.                          zona  and don't  want  any  daylight savings  time
  2014.                          adjustments.
  2015.  
  2016.  
  2017.                     DAY
  2018.                          is the  time zone name for  daylight savings time.
  2019.                          If you  don't use  daylight savings  time in  your
  2020.                          location, you should not supply this or any of the
  2021.                          following fields.
  2022.  
  2023.  
  2024.                          The offset for daylight  time is in the  same form
  2025.                          as  for standard  time.   If you  don't give  this
  2026.                          offset, it  is assumed to  be one hour  later than
  2027.                          standard time.  Thus a more complete specification
  2028.                          of the Eastern time zone would be:
  2029.  
  2030.  
  2031.  
  2032.  
  2033.  
  2034.  
  2035.  
  2036.  
  2037.                                           29
  2038.  
  2039.  
  2040.  
  2041.  
  2042.  
  2043.  
  2044.  
  2045.  
  2046.  
  2047.  
  2048.  
  2049.  
  2050.           CLOCK Version 3.31                               February 4, 1993
  2051.  
  2052.  
  2053.                               TZ=EST+05:00:00EDT+04:00:00
  2054.                                    or
  2055.                               TZ=EST5EDT4                                  
  2056.                                    or
  2057.                               TZ=EST5EDT     (since  daylight  is one  hour
  2058.                                              later by default)
  2059.  
  2060.                     start
  2061.                          is the day  of the year on  which daylight savings
  2062.                          time starts.  There are three formats that you can
  2063.                          use to give this day.  They are given below.
  2064.  
  2065.                     end
  2066.                          is the  day of  the  year on  which standard  time
  2067.                          starts again.   Note  that in  the Southern  hemi-
  2068.                          sphere it is quite possible for "end" to be earli-
  2069.                          er in  the year  than "start" as  daylight savings
  2070.                          time will include December and January.  end is in
  2071.                          the same  format as start.   Note from  the syntax
  2072.                          above  that you  must provide  end if  you provide
  2073.                          start.
  2074.  
  2075.  
  2076.                     time
  2077.                          is the  time of day  that the change  takes place.
  2078.                          It is in exactly the same format  as offset except
  2079.                          that leading  + and -  signs are not allowed.   If
  2080.                          you do not  specify the time, 02:00:00  is used as
  2081.                          the default.
  2082.  
  2083.           The day of the year form for start and end may be any of:
  2084.  
  2085.                     Jn
  2086.                          where n is a Julian day of the year from 1 to 365.
  2087.                          This form does not allow you to  refer to February
  2088.                          29.  Day  59 is always  February 28 and Day  60 is
  2089.                          always March 1.  This  is most useful in locations
  2090.                          where  a  particular calendar  date is  used every
  2091.                          year.
  2092.  
  2093.  
  2094.  
  2095.  
  2096.  
  2097.  
  2098.  
  2099.  
  2100.  
  2101.  
  2102.  
  2103.                                           30
  2104.  
  2105.  
  2106.  
  2107.  
  2108.  
  2109.  
  2110.  
  2111.  
  2112.  
  2113.  
  2114.  
  2115.  
  2116.           CLOCK Version 3.31                               February 4, 1993
  2117.  
  2118.  
  2119.                     n
  2120.                          where n is a Julian day of the year from 0 to 365.
  2121.                          This form  does allow you to refer to February 29.
  2122.                          January  1 is  day 0, February  28 is  day 58, and
  2123.                          either February 29 or March 1 is day 59  depending
  2124.                          on whether it is a leap year or not.  Not the most
  2125.                          useful  of forms but  it does deal  with locations
  2126.                          that might  specify February 29  as the date  that
  2127.                          time changes.
  2128.  
  2129.  
  2130.                     Mm.w.d
  2131.                          is used in places like the U.S. that do not speci-
  2132.                          fy a date,  but rather specify  a rule.  m  is the
  2133.                          month (1  to  12).   d  is  the day  of  the  week
  2134.                          (0=Sunday, 1=Monday,  ... 6=Saturday).   w  is the
  2135.                          week of the month (1 to  5).  Week 1 indicates the
  2136.                          first time that day d occurs in that  month.  Week
  2137.                          5 indicates  the last  time that  day d  occurs in
  2138.                          that  month whether  it is  the 4th  or 5th  time.
  2139.                          Thus the U.S. rule is
  2140.                               M4.1.0/02:00:00,M10.5.0/02:00:00             
  2141.                          or the first Sunday in April at 2AM until the last
  2142.                          Sunday in October at 2AM.
  2143.  
  2144.           The long form for Central U.S. time is:
  2145.  
  2146.                TZ=CST+06:00:00CDT+05:00:00,M4.1.0/02:00:00,M10.5.0/02:00:00
  2147.                          or
  2148.                TZ=CST6CDT5,M4.1.0/2,M10.5.0/2     (just leaving out zeros)
  2149.                          or
  2150.                TZ=CST6CDT,M4.1.0,M10.5.0          (since 2AM is default)
  2151.                          or
  2152.                TZ=CST6CDT                         (since  the U.S.  rule is
  2153.                                                   the default)
  2154.  
  2155.  
  2156.           3.3  Using CLK
  2157.  
  2158.           The most common use of  CLK will be to handle your  time zone and
  2159.           daylight savings time changes.  You need only do the following:
  2160.  
  2161.  
  2162.  
  2163.  
  2164.  
  2165.  
  2166.  
  2167.  
  2168.  
  2169.                                           31
  2170.  
  2171.  
  2172.  
  2173.  
  2174.  
  2175.  
  2176.  
  2177.  
  2178.  
  2179.  
  2180.  
  2181.  
  2182.           CLOCK Version 3.31                               February 4, 1993
  2183.  
  2184.  
  2185.           1.   Set your clocks to UTC.
  2186.  
  2187.           2.   Include the following line in your AUTOEXEC.BAT file.
  2188.  
  2189.                     CLK TZ=:zone   (where  you use  one of  the pre-defined
  2190.                                    zones)
  2191.                          or
  2192.                     CLK TZ=...     (where you define your own rules)
  2193.  
  2194.           That's it.  Everything else will take care of itself.  
  2195.  
  2196.  
  2197.           The only other time you will need to do anything is if you decide
  2198.           to correct your calendar clock to a more accurate time.  You will
  2199.           probably use  TIMESET or one of the  other programs that call the
  2200.           Naval  Observatory or NIST or maybe just your watch that you have
  2201.           set accurately.
  2202.  
  2203.  
  2204.           If you don't want to have to change the configuration of the time
  2205.           setting program,  you may want  to have it  always set UTC  or at
  2206.           least your local standard time.   If you want to have it  set UTC
  2207.           time, do the following:
  2208.  
  2209.  
  2210.                CLK S=C C=W
  2211.                run your time set program
  2212.                CLK TZ=...     (your normal TZ value)
  2213.  
  2214.           The C=W  in the first line  is only required if  you normally run
  2215.           with the clocks disconnected.
  2216.  
  2217.  
  2218.           Note that if you tell the time set program what your current time
  2219.           zone is, you don't have to do anything unless you have the clocks
  2220.           disconnected.
  2221.  
  2222.           Notes     Leaving your clock on local time                    
  2223.                     --------------------------------
  2224.                     If  you don't  want to be  bothered with  UTC, CLK will
  2225.                     quite happily work with your calendar  clock set to its
  2226.                     current value.    For example,  let's  assume that  you
  2227.                     currently have both clocks set to Pacific Standard Time
  2228.                     and you don't  really want to  be bothered changing  to
  2229.                     UTC, but you would like future changes between standard
  2230.                     and daylight  time to be  handled automatically.   Just
  2231.                     use the following statement in AUTOEXEC.BAT:
  2232.  
  2233.  
  2234.  
  2235.                                           32
  2236.  
  2237.  
  2238.  
  2239.  
  2240.  
  2241.  
  2242.  
  2243.  
  2244.  
  2245.  
  2246.  
  2247.  
  2248.           CLOCK Version 3.31                               February 4, 1993
  2249.  
  2250.  
  2251.                          CLK TZ=PST0PDT                                    
  2252.                     CLK believes whatever you tell it and will quite happi-
  2253.                     ly  operate assuming  that PST  is equal  to UTC.   You
  2254.                     could even  use CLK  with  your calendar  clock set  to
  2255.                     Pacific Daylight Time by using:
  2256.                          CLK TZ=PST1PDT
  2257.  
  2258.                     Avoiding missed days when your PC stays on all night,
  2259.                     and missed years and leap days on type 4 and 6 clocks                    
  2260.                     -----------------------------------------------------
  2261.                     If your PC is often left  on over midnight and seems to
  2262.                     miss the change to a new day, use:
  2263.                          CLK C=R TZ=...
  2264.                     in your AUTOEXEC.BAT file to have CLOCK.SYS periodical-
  2265.                     ly read the  time and date from the calendar clock.  If
  2266.                     your clock is  a type 4 or 6 clock  that doesn't update
  2267.                     years automatically and doesn't handle leap days,  then
  2268.                     this setting also ensures that  leaving your PC on over
  2269.                     the end of  a year or across February  29 doesn't cause
  2270.                     you to get the wrong date.
  2271.  
  2272.  
  2273.                     Using CLK.INI to simplify your commands                    
  2274.                     ---------------------------------------
  2275.                     If you always use  the same functions, you may  want to
  2276.                     edit the CLK.INI file that is included in this release.
  2277.                     You can include your TZ=,  C=, and R= functions in  the
  2278.                     file and just use:
  2279.                          CLK /I                                            
  2280.                     in your AUTOEXEC.BAT file.
  2281.  
  2282.                     Adding and subtracting time                    
  2283.                     ---------------------------
  2284.                     You can pretty much do anything including simple arith-
  2285.                     metic on  your clocks  by  using the  functions in  the
  2286.                     correct sequence.   Let's say that  you want to add  12
  2287.                     hours  to the current  time in both  clocks because you
  2288.                     inadvertently  set  AM time  instead of  PM time.   The
  2289.                     following function sequence will do that:
  2290.                          CLK TZ=Igoofed-12 S=D TZ=:pst                     
  2291.                     The TZ=Igoofed-12  (or use any other name for the zone)
  2292.                     sets your DOS clock to 12 hours later than the calendar
  2293.                     clock.  (Yes, I know that time zone offsets seem  back-
  2294.  
  2295.  
  2296.  
  2297.  
  2298.  
  2299.  
  2300.  
  2301.                                           33
  2302.  
  2303.  
  2304.  
  2305.  
  2306.  
  2307.  
  2308.  
  2309.  
  2310.  
  2311.  
  2312.  
  2313.  
  2314.           CLOCK Version 3.31                               February 4, 1993
  2315.  
  2316.  
  2317.                     wards since you  subtract them from the  base time, but
  2318.                     that's the way the official standards have them.)
  2319.  
  2320.  
  2321.                     The S=D sets  both clocks to the value in the DOS clock
  2322.                     with a zero offset.
  2323.  
  2324.                     The  TZ=:pst should be replaced by whatever your normal
  2325.                     TZ  function is or even by a  /I to pull in your normal
  2326.                     settings.
  2327.  
  2328.                     If you normally have your clocks disconnected, insert a
  2329.                     C=W function as the first function.
  2330.  
  2331.                     Correcting inadvertent problems                    
  2332.                     -------------------------------
  2333.                     Just remember that except for the S=D function, CLK and
  2334.                     CLOCK.SYS  always  start with  the assumption  that the
  2335.                     calendar clock is  the base and  do all their  calcula-
  2336.                     tions  from that point.  Thus  you can play with TZ and
  2337.                     other functions as much as you want and always get back
  2338.                     to your normal local time just by  using your normal TZ
  2339.                     command.  The calendar clock will not have been affect-
  2340.                     ed unless you  did something to set  the time or  date.
  2341.                     You can avoid  even that problem by  disconnecting your
  2342.                     clocks  (C=D) or  restricting time  changes (R=A).   In
  2343.                     fact, if you have trouble with some  program messing up
  2344.                     your clocks, try the following:
  2345.  
  2346.  
  2347.                          CLK C=D
  2348.                          execute program
  2349.                          CLK S=C C=W (or C=R) TZ=...  (your normal)
  2350.  
  2351.                     If you  have your standard  C= and  TZ= functions in  a
  2352.                     file, you can simplify this as:                        
  2353.  
  2354.                          CLK C=D
  2355.                          execute program
  2356.                          CLK S=C /I
  2357.  
  2358.                     You  may even  want to  make up batch  files containing
  2359.                     this sequence  to run those troublesome programs.  Some
  2360.                     games are major causes of problems because they set the
  2361.  
  2362.  
  2363.  
  2364.  
  2365.  
  2366.  
  2367.                                           34
  2368.  
  2369.  
  2370.  
  2371.  
  2372.  
  2373.  
  2374.  
  2375.  
  2376.  
  2377.  
  2378.  
  2379.  
  2380.           CLOCK Version 3.31                               February 4, 1993
  2381.  
  2382.  
  2383.                     DOS  clock  running faster  or  slower  than normal  to
  2384.                     control the pace of the game.  As long as  they restore
  2385.                     the normal rate when they exit, the above sequence will
  2386.                     eliminate any clock drift problems.
  2387.  
  2388.                     Fast DOS clock drift                    
  2389.                     --------------------
  2390.                     Some high-speed communication  programs will also cause
  2391.                     the DOS clock  to run slow by causing  the BIOS to miss
  2392.                     clock interrupts.   Fortunately, a C=R function  should
  2393.                     virtually eliminate problems of this type.
  2394.  
  2395.  
  2396.           3.4  Examples
  2397.  
  2398.                clk A=0.34                                                  
  2399.                     sets an adjustment factor of 0.34 seconds per day.  The
  2400.                     A=0.34  function will  be written  to the  CLK.INI file
  2401.                     along with an L=  function with the current time  and a
  2402.                     zero remaining adjustment.  Every time thereafter, that
  2403.                     CLK is run with  the /I option, it will check to see if
  2404.                     it is  time to  adjust the clocks.   About  every third
  2405.                     day, it will add 1 second to both clocks.
  2406.  
  2407.                clk s=c /i
  2408.                     sets the DOS clock to  the current calendar clock  time
  2409.                     without any time  zone adjustment.   The /i causes  all
  2410.                     functions in the  CLK.INI file to be added.   If one of
  2411.                     them  is a tz function, we have corrected the DOS clock
  2412.                     for any changes  made to it and re-established our time
  2413.                     zone.  This is a good command line to use following a 
  2414.                          clk c=d
  2415.                     and other operations that may have led to an  incorrect
  2416.                     time in the DOS clock.
  2417.  
  2418.  
  2419.                clk c=r tz=:est r=b-00:00:02 r=f+00:00:02
  2420.                     sets CLOCK.SYS to read  the calendar clock about  every
  2421.                     10 seconds  and re-synchronize the  DOS clock  with it;
  2422.                     applies the appropriate Eastern time zone (standard  or
  2423.                     daylight depending on date);  and prohibits changes  to
  2424.                     the clock of more than 2 seconds in either direction.
  2425.  
  2426.  
  2427.  
  2428.  
  2429.  
  2430.  
  2431.  
  2432.  
  2433.                                           35
  2434.  
  2435.  
  2436.  
  2437.  
  2438.  
  2439.  
  2440.  
  2441.  
  2442.  
  2443.  
  2444.  
  2445.  
  2446.           CLOCK Version 3.31                               February 4, 1993
  2447.  
  2448.  
  2449.           3.5  Errors
  2450.  
  2451.           When errors are detected, CLK prints a message.  It also sets the
  2452.           ERRORLEVEL on each program termination as follows:
  2453.  
  2454.           0    Normal termination or only warning messages.
  2455.  
  2456.           1    Time outside warning range.  Warning issued.                
  2457.  
  2458.           2    Error in command line or CLK.INI file  functions.  The func-
  2459.                tion with the error is displayed followed by the appropriate
  2460.                usage rules.
  2461.  
  2462.           3    Internal error or system error (e.g., unable to open  handle
  2463.                to CLOCK.SYS).
  2464.  
  2465.  
  2466.  
  2467.           3.6  Future Enhancements
  2468.  
  2469.           Several enhancements are planned for future releases of CLK.
  2470.  
  2471.  
  2472.                -    New  functions for CLK  or a companion  program to help
  2473.                     calculate  the  time  adjustment  factor  (A=  function
  2474.                     value).    You would  provide input  on  the difference
  2475.                     between  the correct time  and the  current time.   You
  2476.                     might get  this from  a good watch  or by  running your
  2477.                     favorite Naval  Observatory/NIST dialer  program.   CLK
  2478.                     will save these differences and the  current time until
  2479.                     it had enough  information to give you a new adjustment
  2480.                     factor.   By  having CLK  or a  related program  do the
  2481.                     calculations,  it  can  automatically account  for  the
  2482.                     adjustments  that  you are  already doing  with  A= but
  2483.                     which aren't quite accurate enough.
  2484.  
  2485.  
  2486.                -    Full  screen interface that displays the current status
  2487.                     of all the things that  CLK and CLOCK.SYS know and lets
  2488.                     you change them just by editing the screen.  The rather
  2489.                     clunky command line  interface needs to  remain as  its
  2490.                     compact function  definitions are  what you  want in  a
  2491.                     .BAT file.
  2492.  
  2493.  
  2494.  
  2495.  
  2496.  
  2497.  
  2498.  
  2499.                                           36
  2500.  
  2501.  
  2502.  
  2503.  
  2504.  
  2505.  
  2506.  
  2507.  
  2508.  
  2509.  
  2510.  
  2511.  
  2512.           CLOCK Version 3.31                               February 4, 1993
  2513.  
  2514.  
  2515.           4  CLKDEMO.EXE
  2516.  
  2517.           A simple version of the CLK  program, called CLKDEMO, is provided
  2518.           in both  executable and source code form.   CLKDEMO only provides
  2519.           support for the C= functions and displaying the clock status.  It
  2520.           is included  to show you  how to add  clock handling to  your own
  2521.           applications.   CLKDEMO  is  written in  C and  is  compiled with
  2522.           Microsoft C 5.1.
  2523.  
  2524.  
  2525.  
  2526.           4.1  CLKDEMO Command Line
  2527.  
  2528.           Syntax    CLKDEMO [C=A|D|R|W] [/?]
  2529.  
  2530.           The functions provided work exactly as  they do in CLK.   CLKDEMO
  2531.           also displays the status and the current times.
  2532.  
  2533.           Since  CLKDEMO.EXE is merely a subset of CLK.EXE, it isn't terri-
  2534.           bly useful as a utility in its own right.  Its value is that  the
  2535.           source code  is  provided.   There are  three  source code  files
  2536.           provided.   CLKDEMO.C  is the  main program and  performs command
  2537.           interpretation and execution.  IOCTL.C is a set of functions that
  2538.           read  and  write the  CLOCK$ device  driver  using the  DOS IOCTL
  2539.           functions.  IOCTL.H  is a set  of definitions which  are used  by
  2540.           CLKDEMO and IOCTL.C.
  2541.  
  2542.  
  2543.  
  2544.  
  2545.  
  2546.  
  2547.  
  2548.  
  2549.  
  2550.  
  2551.  
  2552.  
  2553.  
  2554.  
  2555.  
  2556.  
  2557.  
  2558.  
  2559.  
  2560.  
  2561.  
  2562.  
  2563.  
  2564.  
  2565.                                           37
  2566.  
  2567.  
  2568.  
  2569.  
  2570.  
  2571.  
  2572.  
  2573.  
  2574.  
  2575.  
  2576.  
  2577.  
  2578.           CLOCK Version 3.31                               February 4, 1993
  2579.  
  2580.  
  2581.           5  IOCTL - API TO CLOCK.SYS
  2582.  
  2583.           IOCTL  is provided to allow you to build your own applications to
  2584.           use  the additional functions that CLOCK.SYS provides.  There are
  2585.           several  APIs  (Application Programming  Interfaces)  provided as
  2586.           part of  IOCTL.  These  APIs are sufficient to perform all of the
  2587.           extended functions.
  2588.  
  2589.           All of  the APIs  are defined  to be directly  callable from  all
  2590.           Microsoft  compatible languages including  MASM, FORTRAN, Pascal,
  2591.           and BASIC.   Languages other  than C  refer to the  API names  as
  2592.           upper case characters.  Object code versions are provided for the
  2593.           small, medium,  and large  memory models.   These  may be  linked
  2594.           directly with your  applications.  The  object code versions  are
  2595.           SIOCTL.OBJ, MIOCTL.OBJ, and LIOCTL.OBJ for the small, medium, and
  2596.           large models respectively.
  2597.  
  2598.  
  2599.           5.1  Data Structures
  2600.  
  2601.           Data structures are defined in ioctl.h that are used in the calls
  2602.           to the IOCTL functions.
  2603.  
  2604.  
  2605.             /* "modes" holds flags that control the operation of CLOCK.SYS   */
  2606.  
  2607.             struct modes {
  2608.                 unsigned : 9;                                              
  2609.                 unsigned day_light: 1;
  2610.                 unsigned disp_24 : 1;
  2611.                 unsigned disp_tim : 1;
  2612.                 unsigned pw_ena : 1;
  2613.                 unsigned disabl : 1;
  2614.                 unsigned chk_forw : 1;                                     
  2615.                 unsigned chk_back : 1;
  2616.             };
  2617.  
  2618.  
  2619.  
  2620.  
  2621.  
  2622.  
  2623.  
  2624.  
  2625.  
  2626.  
  2627.  
  2628.  
  2629.  
  2630.  
  2631.                                                   38
  2632.  
  2633.  
  2634.  
  2635.  
  2636.  
  2637.  
  2638.  
  2639.  
  2640.  
  2641.  
  2642.  
  2643.  
  2644.             CLOCK Version 3.31                               February 4, 1993
  2645.  
  2646.  
  2647.             /* "off" holds a time offset in hours, minutes, and seconds.   */
  2648.  
  2649.             struct off {
  2650.                 int hour;                                                    
  2651.                 int minute;
  2652.                 int second;
  2653.             };
  2654.  
  2655.             /* "date_time"is a structure that holds a date and time.      */
  2656.  
  2657.  
  2658.             struct date_time {
  2659.                 int year;
  2660.                 int month;
  2661.                 int day;
  2662.                 struct off time;
  2663.                 int hsecond;                                                 
  2664.             };
  2665.  
  2666.             /* "time_zone" holds a time zone name and offset.          */
  2667.  
  2668.             struct time_zone {
  2669.                 struct off offs;                                             
  2670.                 unsigned char zone[32];
  2671.             };
  2672.  
  2673.             /* "limit" is used to hold the data that sets time limits for 
  2674.                changes.  */
  2675.  
  2676.             struct limit {                                                   
  2677.                 struct off back;
  2678.                 struct off forward;
  2679.             };
  2680.  
  2681.             /* "disp" is used to hold the data that specifies the location 
  2682.                and attributes of the continuous time display.             */
  2683.  
  2684.             struct disp {
  2685.                 int x;
  2686.                 int y;
  2687.                 int attribute;
  2688.             };
  2689.  
  2690.  
  2691.  
  2692.  
  2693.  
  2694.  
  2695.  
  2696.  
  2697.                                                   39
  2698.  
  2699.  
  2700.  
  2701.  
  2702.  
  2703.  
  2704.  
  2705.  
  2706.  
  2707.  
  2708.  
  2709.  
  2710.             CLOCK Version 3.31                               February 4, 1993
  2711.  
  2712.  
  2713.             /* CLOCK_DATA is the CLOCK.SYS data that is returned by clksta
  2714.                (AKA CLKSTA for FORTRAN, Pascal, and BASIC languages).  
  2715.                Because we need to be language independent, all of the data
  2716.                is word-aligned. Only the data types int and character are
  2717.                used. Some of the int data is encoded bits or addresses. */
  2718.  
  2719.             struct CLOCK_DATA {
  2720.                 int connected;               /* Connection state     */
  2721.                 struct modes mode;           /* Mode bits           */
  2722.                 struct date_timecal_time;    /* Current date and time */
  2723.                 struct time_zone standard;   /* Offset of standard UTC */
  2724.                 struct time_zone daylight;   /* Daylight offset      */
  2725.                 struct limitrules;           /* Maximum clock movement */
  2726.                 structdisp display;          /* Time display loc and attr*/
  2727.                 unsignedchar vers[6];        /* CLOCK.SYS version nnn.nn*/
  2728.                 int clock_type;              /* Type of clock installed */
  2729.                 int ct_1;                    /* Data for clock type    */
  2730.                 int ct_2;
  2731.                 int ct_3;
  2732.                 int ct_4;
  2733.                 unsigned intclock_seg;       /* Segment CLOCK.SYS loaded at */
  2734.                 unsigned int clock_long;     /* Size of CLOCK.SYS          */
  2735.             };
  2736.  
  2737.  
  2738.           This data structure is treated as the following integer  array in
  2739.           the FORTRAN and BASIC languages.
  2740.  
  2741.           BASIC          
  2742.           -----
  2743.                OPTION BASE 1
  2744.                DIM CDATA(66)
  2745.  
  2746.           FORTRAN          
  2747.           -------
  2748.                INTEGER*2 CDATA(66)
  2749.  
  2750.  
  2751.           ARRAY INDEX         CONTENTS                 STRUCTURE ELEMENT          
  2752.           -----------         --------                 -----------------
  2753.           CDATA(1)       =    Connection state         connected
  2754.           CDATA(2)       =    Mode bits                mode
  2755.           CDATA(3)       =    Year from calendar clock cal_time.year
  2756.           CDATA(4)       =    Month                    cal_time.month   
  2757.           CDATA(5)       =    Day                      cal_time.day
  2758.           CDATA(6)       =    Hour                     cal_time.offs.hour
  2759.  
  2760.  
  2761.  
  2762.  
  2763.                                           40
  2764.  
  2765.  
  2766.  
  2767.  
  2768.  
  2769.  
  2770.  
  2771.  
  2772.  
  2773.  
  2774.  
  2775.  
  2776.           CLOCK Version 3.31                               February 4, 1993
  2777.  
  2778.  
  2779.           CDATA(7)       =    Minute                   cal_time.offs.minute
  2780.           CDATA(8)       =    Second                   cal_time.offs.second
  2781.           CDATA(9)       =    100th of second          cal_time.hsecond 
  2782.           CDATA(10)      =    Standard hours from UTC  standard.offs.hour
  2783.           CDATA(11)      =    Standard minutes         standard.offs.minute
  2784.           CDATA(12)      =    Standard seconds         standard.offs.second
  2785.           CDATA(13) -                                  standard.zone
  2786.           CDATA(28)      =    Standard time zone LJSF
  2787.           CDATA(29)      =    Daylight hours from UTC  daylight.offs.hour
  2788.           CDATA(30)      =    Daylight minutes         daylight.offs.minute
  2789.           CDATA(31)      =    Daylight seconds         daylight.offs.second
  2790.           CDATA(32) -                                  daylight.zone
  2791.           CDATA(47)      =    Daylight time zone LJSF
  2792.           CDATA(48)      =    Maximum hours backward   rules.back.hour
  2793.           CDATA(49)      =    Maximum minutes backward rules.back.minute 
  2794.           CDATA(50)      =    Maximum seconds backward rules.back.second
  2795.           CDATA(51)      =    Maximum hours forward    rules.forward.hour
  2796.           CDATA(52)      =    Maximum minutes forward  rules.forward.minute
  2797.           CDATA(53)      =    Maximum seconds forward  rules.forward.second
  2798.           CDATA(54)      =    x cursor position        display.x
  2799.           CDATA(55)      =    y cursor position        display.y           
  2800.           CDATA(56)      =    attribute                display.attribute
  2801.           CDATA(57) -                                  vers
  2802.           CDATA(59)      =    CLOCK.SYS version LJSF
  2803.           CDATA(60)      =    Clock type               clock_type
  2804.           CDATA(61)      =    I/O address, base memory ct_1
  2805.                               segment, or base year                        
  2806.           CDATA(62)      =    Read memory offset       ct_2
  2807.           CDATA(63)      =    Write-0 memory offset    ct_3
  2808.           CDATA(64)      =    Write-1 memory offset    ct_4
  2809.           CDATA(65)      =    Segment address          clock_seg
  2810.                               where CLOCK.SYS is loaded
  2811.           CDATA(66)      =    Length of CLOCK.SYS      clock_long
  2812.  
  2813.  
  2814.  
  2815.  
  2816.  
  2817.  
  2818.  
  2819.  
  2820.  
  2821.  
  2822.  
  2823.  
  2824.  
  2825.  
  2826.  
  2827.  
  2828.  
  2829.                                           41
  2830.  
  2831.  
  2832.  
  2833.  
  2834.  
  2835.  
  2836.  
  2837.  
  2838.  
  2839.  
  2840.  
  2841.  
  2842.           CLOCK Version 3.31                               February 4, 1993
  2843.  
  2844.  
  2845.           5.2  clksta
  2846.  
  2847.           ■  Summary
  2848.  
  2849.  
  2850.           C          
  2851.           -
  2852.  
  2853.           #include <ioctl.h>
  2854.  
  2855.           extern int pascal far clksta(struct CLOCK_DATA *cdata);
  2856.  
  2857.           BASIC          
  2858.           -----
  2859.  
  2860.           OPTION BASE 1
  2861.           DIM CDATA(66)
  2862.  
  2863.           DECLARE FUNCTION CLKSTA%(BYVAL Addr AS INTEGER)
  2864.  
  2865.           STATUS% = CLKSTA(VARPTR(CDATA(1)))
  2866.  
  2867.           FORTRAN          
  2868.           -------
  2869.  
  2870.           INTEGER*2 CDATA(66)
  2871.           INTEGER*2 STATUS
  2872.           INTEGER*2 CLKSTA
  2873.  
  2874.           STATUS = CLKSTA(CDATA)
  2875.  
  2876.  
  2877.           ■  Description
  2878.  
  2879.           clksta  returns  all  of the  information  about  CLOCK.SYS  in a
  2880.           structure.  In FORTRAN and  BASIC the structure appears to  be an
  2881.           integer array.  The above structure declarations can be  approxi-
  2882.           mated  in Pascal.  For  a description of the  values of each ele-
  2883.           ment, see the individual APIs below.  The elements  not described
  2884.           as part of the input to other functions are:
  2885.  
  2886.           unsigned char vers[6];        /* CLOCK.SYS version nnn.nn */
  2887.           int clock_type;               /* Type of clock installed  */
  2888.  
  2889.  
  2890.  
  2891.  
  2892.  
  2893.  
  2894.  
  2895.                                           42
  2896.  
  2897.  
  2898.  
  2899.  
  2900.  
  2901.  
  2902.  
  2903.  
  2904.  
  2905.  
  2906.  
  2907.  
  2908.           CLOCK Version 3.31                               February 4, 1993
  2909.  
  2910.  
  2911.           int ct_1;                       /* Data for clock type */
  2912.           int ct_2;                                                    
  2913.           int ct_3;
  2914.           int ct_4;
  2915.           unsigned int clock_seg;         /* Segment  CLOCK.SYS loaded at */
  2916.           unsigned int clock_long;        /* Size of CLOCK.SYS  */
  2917.  
  2918.           CDATA(57) -
  2919.           CDATA(59)      =    CLOCK.SYS version LJSF characters
  2920.           CDATA(60)      =    Clock type (see type numbers in appendix B)
  2921.           CDATA(61)      =    I/O  address,  base memory  segment,  
  2922.                               or base year
  2923.           CDATA(62)      =    Read memory offset
  2924.           CDATA(63)      =    Write-0 memory offset
  2925.           CDATA(64)      =    Write-1 memory offset
  2926.           CDATA(65)      =    Segment address at which CLOCK.SYS is loaded
  2927.           CDATA(66)      =    Length in bytes of CLOCK.SYS
  2928.  
  2929.  
  2930.                vers or CDATA(57) - CDATA(59)
  2931.                     Is the  version number  of  the CLOCK.SYS  that is  in-
  2932.                     stalled.    This is  returned as  a  6-character, left-
  2933.                     justified, space-filled  (LJSF) character string.   For
  2934.                     example, "3.49  ".
  2935.  
  2936.  
  2937.                clock_type or CDATA(60)
  2938.                     Is the type number of the clock being used.  See Appen-
  2939.                     dix B for the type numbers.
  2940.  
  2941.                ct_1 or CDATA(61)
  2942.                     Is the value of the first clock parameter.  This is the
  2943.                     base  I/O address for  I/O bus clocks,  the base memory
  2944.                     segment address for  memory-mapped clocks, or  the base
  2945.                     year for the AT&T clocks.
  2946.  
  2947.                ct_2 or CDATA(62)
  2948.                     Is the read offset for memory-mapped clocks.
  2949.  
  2950.  
  2951.  
  2952.  
  2953.  
  2954.  
  2955.  
  2956.  
  2957.  
  2958.  
  2959.  
  2960.  
  2961.                                           43
  2962.  
  2963.  
  2964.  
  2965.  
  2966.  
  2967.  
  2968.  
  2969.  
  2970.  
  2971.  
  2972.  
  2973.  
  2974.           CLOCK Version 3.31                               February 4, 1993
  2975.  
  2976.  
  2977.                ct_3 or CDATA(63)
  2978.                     Is the write 0-bits offset for memory-mapped clocks.
  2979.  
  2980.  
  2981.                ct_4 or CDATA(64)
  2982.                     Is the write 1-bits offset for memory-mapped clocks.
  2983.  
  2984.                clock_seg or CDATA(65)
  2985.                     Is the  segment address at  which CLOCK.SYS is  loaded.
  2986.                     CLOCK.SYS always starts at offset zero in this segment.
  2987.  
  2988.  
  2989.                clock_long or CDATA(66)
  2990.                     Is the length of CLOCK.SYS in bytes.
  2991.  
  2992.           ■ Arguments         cdata
  2993.                                    is  a pointer to a location to place the
  2994.                                    current    state     information    from
  2995.                                    CLOCK.SYS.
  2996.  
  2997.           ■  Return Value
  2998.  
  2999.           If clksta is  successful, the function returns 0.   Otherwise, it
  3000.           returns a non-zero  value and _doserrno is set to the correspond-
  3001.           ing error code.  Possible values are:
  3002.  
  3003.                0001h     Invalid  function.    This  should  indicate  that
  3004.                          CLOCK.SYS is not installed.  It  is the error that
  3005.                          the DOS clock device driver  would return since it
  3006.                          doesn't handle these functions.
  3007.  
  3008.                0005h     Access denied.  Indicates that DOS would not  open
  3009.                          a handle for read access.  You may not have enough
  3010.                          handles available.
  3011.  
  3012.  
  3013.                0006h     Invalid handle.  Should not happen.
  3014.  
  3015.                000Dh     Invalid data.  CLOCK.SYS reported a bad byte count
  3016.                          or otherwise  did not process  the request.   This
  3017.                          should not happen.
  3018.  
  3019.  
  3020.  
  3021.  
  3022.  
  3023.  
  3024.  
  3025.  
  3026.  
  3027.                                           44
  3028.  
  3029.  
  3030.  
  3031.  
  3032.  
  3033.  
  3034.  
  3035.  
  3036.  
  3037.  
  3038.  
  3039.  
  3040.           CLOCK Version 3.31                               February 4, 1993
  3041.  
  3042.  
  3043.           5.3  setpw
  3044.  
  3045.           ■ Summary
  3046.  
  3047.           C          
  3048.           -
  3049.  
  3050.           #include <ioctl.h>
  3051.  
  3052.           extern void pascal far setpw(unsigned char *pw);
  3053.  
  3054.  
  3055.           BASIC          
  3056.           -----
  3057.  
  3058.           DECLARE SUB SETPW(BYVAL S AS INTEGER)
  3059.  
  3060.           A$ = "MyPasswd"
  3061.  
  3062.           CALL SETPW(SADD(A$))
  3063.  
  3064.           Note that A$  must be at least 8 characters long.  Only the first
  3065.           8 characters will be used.
  3066.  
  3067.           FORTRAN          
  3068.           -------
  3069.  
  3070.           CHARACTER*8 PW
  3071.  
  3072.           PW = "MyPasswd"
  3073.           CALL SETPW(PW)
  3074.  
  3075.           ■  Description
  3076.  
  3077.           The  setpw function sets  the password  to be used  on subsequent
  3078.           calls to any  of the following functions.   These functions auto-
  3079.           matically  supply   the  most  recent  password  when  they  call
  3080.           CLOCK.SYS.   You need not  ever call setpw  if you are  not using
  3081.           password protection.  CLOCK.SYS will  only check the password  if
  3082.           password protection is enabled through the stmode function.
  3083.  
  3084.  
  3085.  
  3086.  
  3087.  
  3088.  
  3089.  
  3090.  
  3091.  
  3092.  
  3093.                                           45
  3094.  
  3095.  
  3096.  
  3097.  
  3098.  
  3099.  
  3100.  
  3101.  
  3102.  
  3103.  
  3104.  
  3105.  
  3106.           CLOCK Version 3.31                               February 4, 1993
  3107.  
  3108.  
  3109.           ■ Arguments         pw
  3110.                                    is  a  pointer to  the  password string.
  3111.                                    This string should be exactly 8  charac-
  3112.                                    ters long and must be at least 8 charac-
  3113.                                    ters long.  The  password should also be
  3114.                                    LJSF as every  character is significant.
  3115.                                    Case is significant in passwords.
  3116.  
  3117.           ■  Example
  3118.  
  3119.  
  3120.           #include <ioctl.h>
  3121.  
  3122.             main()
  3123.  
  3124.             {
  3125.                     unsigned char pw[9] = "MyPasswd";
  3126.  
  3127.  
  3128.             /* Set password to use on subsequent function calls.  */
  3129.  
  3130.                     setpw(pw);
  3131.  
  3132.             }
  3133.  
  3134.  
  3135.  
  3136.           5.4  connec
  3137.  
  3138.           ■  Summary
  3139.  
  3140.           C          
  3141.           -
  3142.  
  3143.           #include <ioctl.h>
  3144.  
  3145.           extern int pascal far connec(int *conn);
  3146.  
  3147.           BASIC          
  3148.           -----
  3149.  
  3150.           DECLARE FUNCTION CONNEC%(CONN AS INTEGER)
  3151.  
  3152.           STATUS% = CONNEC(CONN)
  3153.  
  3154.  
  3155.           FORTRAN          
  3156.           -------
  3157.  
  3158.  
  3159.                                           46
  3160.  
  3161.  
  3162.  
  3163.  
  3164.  
  3165.  
  3166.  
  3167.  
  3168.  
  3169.  
  3170.  
  3171.  
  3172.           CLOCK Version 3.31                               February 4, 1993
  3173.  
  3174.  
  3175.           INTEGER*2 CONN, STATUS, CONNEC
  3176.  
  3177.           STATUS = CONNEC(CONN)
  3178.  
  3179.  
  3180.           ■  Description
  3181.  
  3182.           The  connec function provides  a means of  setting the connection
  3183.           state of CLOCK.SYS.
  3184.  
  3185.  
  3186.           ■  Arguments   conn
  3187.                               specifies the  new connection mode.  The val-
  3188.                               ues are:
  3189.                               0 = disconnected (C=D)
  3190.                               1 = connected for writes only (C=W)
  3191.                               2 =  connected for writes and  periodic reads
  3192.                               (C=R)
  3193.                               3 = connected for all operations (C=A)
  3194.  
  3195.  
  3196.           ■ Return Value
  3197.  
  3198.  
  3199.           If the  return value  is zero,  the function  succeeded.   If the
  3200.           return value is non-zero, an error  has occurred and _doserrno is
  3201.           set to the corresponding error code.  Possible values are:
  3202.  
  3203.                0001h     Invalid  function.    This  should  indicate  that
  3204.                          CLOCK.SYS is not installed.   It is the error that
  3205.                          the DOS clock device driver would  return since it
  3206.                          doesn't handle these functions.
  3207.  
  3208.                0005h     Access  denied.  Indicates that DOS would not open
  3209.                          a handle for read access.  You may not have enough
  3210.                          handles available.
  3211.  
  3212.  
  3213.                0006h     Invalid handle.  Should not happen.
  3214.  
  3215.                000Dh     Invalid data.  CLOCK.SYS reported a bad byte count
  3216.                          or otherwise did  not process the  request.   This
  3217.                          should not happen.
  3218.  
  3219.  
  3220.  
  3221.  
  3222.  
  3223.  
  3224.  
  3225.                                           47
  3226.  
  3227.  
  3228.  
  3229.  
  3230.  
  3231.  
  3232.  
  3233.  
  3234.  
  3235.  
  3236.  
  3237.  
  3238.           CLOCK Version 3.31                               February 4, 1993
  3239.  
  3240.  
  3241.           ■  Example
  3242.  
  3243.           #include <stdio.h>
  3244.             #include <ioctl.h>
  3245.  
  3246.  
  3247.             main()
  3248.             {
  3249.                   int conn_write = 1;
  3250.                   int status;
  3251.  
  3252.  
  3253.             /* Set clock to connected for writes */
  3254.  
  3255.                   status = connec(&conn_write);
  3256.                   if (status)
  3257.                         printf("Error %X in connec\n", status);
  3258.             }
  3259.  
  3260.  
  3261.  
  3262.           5.5  newpw
  3263.  
  3264.           ■  Summary
  3265.  
  3266.           C          
  3267.           -
  3268.  
  3269.           #include <ioctl.h>
  3270.  
  3271.           extern int pascal far newpw(unsigned char *pw);
  3272.  
  3273.  
  3274.           BASIC          
  3275.           -----
  3276.  
  3277.           DECLARE FUNCTION NEWPW%(BYVAL S AS INTEGER)
  3278.  
  3279.           A$ = "MyPasswd"
  3280.  
  3281.           STATUS% = NEWPW(SADD(A$))
  3282.  
  3283.           Note that A$ must be at least 8 characters long.   Only the first
  3284.           8 characters will be used.
  3285.  
  3286.  
  3287.  
  3288.  
  3289.  
  3290.                
  3291.                                           48
  3292.  
  3293.  
  3294.  
  3295.  
  3296.  
  3297.  
  3298.  
  3299.  
  3300.  
  3301.  
  3302.  
  3303.  
  3304.           CLOCK Version 3.31                               February 4, 1993
  3305.  
  3306.  
  3307.           FORTRAN          
  3308.           -------
  3309.  
  3310.           CHARACTER*8 PW
  3311.  
  3312.           INTEGER*2 STATUS, NEWPW
  3313.  
  3314.           PW = "MyPasswd"
  3315.           STATUS = NEWPW(PW)
  3316.  
  3317.           ■  Description
  3318.  
  3319.           The  newpw function  sets a  new  password for  CLOCK.SYS.   This
  3320.           function is  not sufficient to  enable password protection.   You
  3321.           must also  use stmode to turn  on password checking.   BE SURE to
  3322.           use newpw before you use stmode to turn on password checking.  If
  3323.           you turn on password checking without first setting  the password
  3324.           to  something that you  know, you will  never be able  to use the
  3325.           CLOCK.SYS functions again until you reboot.
  3326.  
  3327.           ■ Arguments         pw
  3328.                                    is  a  pointer to  the  password string.
  3329.                                    This string should be exactly 8  charac-
  3330.                                    ters long and must be at least 8 charac-
  3331.                                    ters long.  The password  should also be
  3332.                                    LJSF as every  character is significant.
  3333.                                    Case is significant in passwords.
  3334.  
  3335.           ■ Return Value
  3336.  
  3337.  
  3338.           If the  return value is  zero, the  function succeeded.   If  the
  3339.           return value is non-zero, an error has  occurred and _doserrno is
  3340.           set to the corresponding error code.  Possible values are:
  3341.  
  3342.                0001h     Invalid  function.    This  should  indicate  that
  3343.                          CLOCK.SYS is not installed.  It is  the error that
  3344.                          the DOS clock device driver  would return since it
  3345.                          doesn't handle these functions.
  3346.  
  3347.                0005h     Access denied.  Indicates that DOS would not  open
  3348.                          a handle for read access.  You may not have enough
  3349.                          handles available.
  3350.  
  3351.  
  3352.  
  3353.  
  3354.  
  3355.  
  3356.  
  3357.                                           49
  3358.  
  3359.  
  3360.  
  3361.  
  3362.  
  3363.  
  3364.  
  3365.  
  3366.  
  3367.  
  3368.  
  3369.  
  3370.           CLOCK Version 3.31                               February 4, 1993
  3371.  
  3372.  
  3373.                0006h     Invalid handle.  Should not happen.
  3374.  
  3375.                000Dh     Invalid data.  CLOCK.SYS reported a bad byte count
  3376.                          or  otherwise did not  process the  request.  This
  3377.                          should not happen.
  3378.  
  3379.  
  3380.           ■  Example
  3381.  
  3382.           #include <stdio.h>
  3383.  
  3384.             #include <ioctl.h>
  3385.  
  3386.             main()
  3387.  
  3388.             {
  3389.                     unsigned char pw[9] = "MyPasswd";
  3390.  
  3391.                     int status;
  3392.  
  3393.             /* Set new password for CLOCK.SYS  */
  3394.  
  3395.                     status = setpw(pw);
  3396.                     if (status)
  3397.  
  3398.                         printf("Error %X in setpw\n", status);
  3399.  
  3400.             }
  3401.  
  3402.  
  3403.  
  3404.           5.6  rstrct
  3405.  
  3406.           ■  Summary
  3407.  
  3408.           C          
  3409.           -
  3410.  
  3411.           #include <ioctl.h>
  3412.  
  3413.           extern int pascal far rstrct(int *bhour, int *bmin, int *bsec,
  3414.               int *fhour, int *fmin, int *fsec);
  3415.  
  3416.  
  3417.  
  3418.  
  3419.  
  3420.  
  3421.  
  3422.  
  3423.                                           50
  3424.  
  3425.  
  3426.  
  3427.  
  3428.  
  3429.  
  3430.  
  3431.  
  3432.  
  3433.  
  3434.  
  3435.  
  3436.           CLOCK Version 3.31                               February 4, 1993
  3437.  
  3438.  
  3439.           BASIC          
  3440.           -----
  3441.  
  3442.           DECLARE  FUNCTION RSTRCT%(BHOUR%,  BMIN%,  BSEC%, FHOUR%,  FMIN%,
  3443.           FSEC%)
  3444.  
  3445.           FORTRAN          
  3446.           -------
  3447.  
  3448.           INTEGER*2 BHOUR, BMIN, BSEC, FHOUR, FMIN, FSEC
  3449.           INTEGER*2 RSTRCT
  3450.  
  3451.  
  3452.           STATUS = RSTRCT(BHOUR, BMIN, BSEC, FHOUR, FMIN, FSEC)
  3453.  
  3454.           ■  Description
  3455.  
  3456.           The rstrct  function sets backwards  and forwards limits  on time
  3457.           changes.   Any  time changes  that  exceed these  limits will  be
  3458.           ignored.  For example,  if a backward limit of 2  seconds is set,
  3459.           no change that would move the clock backwards more than 2 seconds
  3460.           will be processed.  Setting the limits protects you agains keying
  3461.           in a  bad time and agains  programs that may  incorrectly set the
  3462.           time.  Yet you  can still change the  time within the  prescribed
  3463.           limits.  For example, you  may set a backward limit of  2 seconds
  3464.           to permit CLK to adjust the time by up to 2  seconds while inhib-
  3465.           iting any  other backwards changes.  These  limits have no effect
  3466.           on changing  between standard and daylight  times as that  is not
  3467.           really a change in the "time".
  3468.  
  3469.  
  3470.           ■ Arguments         bhour:bmin:bsec
  3471.                                    is the backward limit  in hours, minutes
  3472.                                    and seconds.
  3473.  
  3474.                               fhour:fmin:fsec
  3475.                                    is the forward limit in hours,  minutes,
  3476.                                    and seconds.
  3477.  
  3478.           ■ Return Value
  3479.  
  3480.           If the  return value  is zero,  the function  succeeded.   If the
  3481.           return value is non-zero, an  error has occurred and _doserrno is
  3482.           set to the corresponding error code.  Possible values are:
  3483.  
  3484.  
  3485.  
  3486.  
  3487.  
  3488.  
  3489.                                           51
  3490.  
  3491.  
  3492.  
  3493.  
  3494.  
  3495.  
  3496.  
  3497.  
  3498.  
  3499.  
  3500.  
  3501.  
  3502.           CLOCK Version 3.31                               February 4, 1993
  3503.  
  3504.  
  3505.                0001h     Invalid  function.    This  should  indicate  that
  3506.                          CLOCK.SYS is not  installed.  It is the error that
  3507.                          the DOS clock device driver  would return since it
  3508.                          doesn't handle these functions.
  3509.  
  3510.                0005h     Access denied.  Indicates that DOS would not  open
  3511.                          a handle for read access.  You may not have enough
  3512.                          handles available.
  3513.  
  3514.  
  3515.                0006h     Invalid handle.  Should not happen.
  3516.  
  3517.                000Dh     Invalid data.  CLOCK.SYS reported a bad byte count
  3518.                          or otherwise  did not process  the request.   This
  3519.                          should not happen.
  3520.  
  3521.  
  3522.  
  3523.           ■  Example
  3524.  
  3525.           #include <stdio.h>
  3526.           #include <ioctl.h>
  3527.  
  3528.           main()
  3529.  
  3530.           {
  3531.               int bhour = 0;
  3532.               int bmin = 0;
  3533.               int bsec = 2;
  3534.               int fhour = 1;
  3535.               int fmin = 0;
  3536.               int fsec = 0;
  3537.               int status;
  3538.  
  3539.            /* Set time change limits to 2 seconds backwards and 1 hour 
  3540.               forwards */
  3541.  
  3542.  
  3543.               status = rstrct(&bhour, &bmin, &bsec, &fhour, &fmin, &fsec);
  3544.               if (status)
  3545.                    printf("Error %X in rstrct\n", status);
  3546.                else
  3547.                    printf("Time limits set to -%.2d:%.2d:%.2d,+%.2d:%.2d:%"
  3548.                        ".2d\n", bhour, bmin, bsec, fhour, fmin, fsec);
  3549.  
  3550.           }
  3551.  
  3552.  
  3553.  
  3554.  
  3555.                                           52
  3556.  
  3557.  
  3558.  
  3559.  
  3560.  
  3561.  
  3562.  
  3563.  
  3564.  
  3565.  
  3566.  
  3567.  
  3568.           CLOCK Version 3.31                               February 4, 1993
  3569.  
  3570.  
  3571.  
  3572.           5.7  stmode
  3573.  
  3574.  
  3575.           ■  Summary
  3576.  
  3577.           C          
  3578.           -
  3579.  
  3580.           #include <ioctl.h>
  3581.  
  3582.           extern int pascal far stmode(struct modes *mode);
  3583.  
  3584.           BASIC          
  3585.           -----
  3586.  
  3587.           DECLARE FUNCTION STMODE%(MODES%)
  3588.  
  3589.  
  3590.           FORTRAN          
  3591.           -------
  3592.  
  3593.           INTEGER*2 MODES
  3594.           INTEGER*2 STMODE
  3595.  
  3596.           STATUS = STMODE(MODES)
  3597.  
  3598.  
  3599.           ■  Description
  3600.  
  3601.           The stmode  function  sets a  variety of  operating  modes.   The
  3602.           argument is  actually a  structure of bits.   Each  bit specifies
  3603.           whether an operating mode is on (1) or off (0).
  3604.  
  3605.  
  3606.           ■ Arguments         modes
  3607.                                    is  set of  bits that  specify operating
  3608.                                    modes.  The bit values are:     
  3609.  
  3610.                                    unsigned : 9;            Unused
  3611.                                    unsigned day_light: 1;   0x0200 (512)
  3612.                                    unsigned disp_24 : 1;    0x0400 (1024)
  3613.                                    unsigned disp_tim : 1;   0x0800 (2048)
  3614.                                    unsigned pw_ena : 1;     0x1000 (4096)
  3615.                                    unsigned disabl : 1;     0x2000 (8192)
  3616.                                    unsigned chk_forw : 1;   0x4000 (16384)
  3617.                                    unsigned chk_back : 1;   0x8000 (32768)
  3618.  
  3619.           
  3620.  
  3621.                                           53
  3622.  
  3623.  
  3624.  
  3625.  
  3626.  
  3627.  
  3628.  
  3629.  
  3630.  
  3631.  
  3632.  
  3633.  
  3634.           CLOCK Version 3.31                               February 4, 1993
  3635.  
  3636.  
  3637.           ■ Return Value
  3638.  
  3639.  
  3640.           If the  return value  is zero,  the function  succeeded.   If the
  3641.           return value is non-zero, an  error has occurred and _doserrno is
  3642.           set to the corresponding error code.  Possible values are:
  3643.  
  3644.                0001h     Invalid  function.    This  should  indicate  that
  3645.                          CLOCK.SYS is not installed.   It is the error that
  3646.                          the DOS clock device driver  would return since it
  3647.                          doesn't handle these functions.
  3648.  
  3649.                0005h     Access denied.  Indicates that DOS would not  open
  3650.                          a handle for read access.  You may not have enough
  3651.                          handles available.
  3652.  
  3653.                0006h     Invalid handle.  Should not happen.
  3654.  
  3655.                000Dh     Invalid data.  CLOCK.SYS reported a bad byte count
  3656.                          or otherwise  did not process  the request.   This
  3657.                          should not happen.
  3658.  
  3659.  
  3660.           ■  Example
  3661.  
  3662.           #include <ioctl.h>
  3663.  
  3664.  
  3665.             main()
  3666.  
  3667.             {
  3668.                   struct CLOCK_DATA cdata;
  3669.  
  3670.             /* Set daylight savings time.  */
  3671.  
  3672.  
  3673.                   clksta(&cdata);            /* Get current mode settings. */
  3674.  
  3675.                   cdata.mode.day_light = 1;/* Turn on daylight */
  3676.  
  3677.                   stmode(&cdata.modes);
  3678.  
  3679.             }
  3680.  
  3681.  
  3682.  
  3683.  
  3684.  
  3685.  
  3686.  
  3687.                                           54
  3688.  
  3689.  
  3690.  
  3691.  
  3692.  
  3693.  
  3694.  
  3695.  
  3696.  
  3697.  
  3698.  
  3699.  
  3700.           CLOCK Version 3.31                               February 4, 1993
  3701.  
  3702.  
  3703.  
  3704.           5.8  stzone
  3705.  
  3706.  
  3707.           ■  Summary
  3708.  
  3709.           C          
  3710.           -
  3711.  
  3712.           #include <ioctl.h>
  3713.  
  3714.           extern int pascal far stzone(int *shour, int *smin, int *ssec,
  3715.               unsigned char sname[32], int *dhour, int *dmin,
  3716.               int *dsec, unsigned char dname[32]);
  3717.  
  3718.  
  3719.           BASIC          
  3720.           -----
  3721.  
  3722.  
  3723.           DECLARE  FUNCTION  STZONE%(SHOUR%,  SMIN%,  SSEC%,  BYVAL  SN  AS
  3724.           INTEGER, DHOUR%, DMIN%, DSEC%, BYVAL DN AS INTEGER)
  3725.  
  3726.           SNAME$ = "32-CHARACTER STANDARD ZONE NAME "
  3727.           DNAME$ = "Daylight savings time zone name "
  3728.  
  3729.  
  3730.           STATUS% = STZONE(6,0,0,SADD(SNAME$),5,0,0,SADD(DNAME$))
  3731.  
  3732.           FORTRAN          
  3733.           -------
  3734.  
  3735.           CHARACTER*32 SNAME, DNAME
  3736.           INTEGER*2 STZONE, STATUS
  3737.  
  3738.           SNAME = "CST"
  3739.           DNAME = "CDT"
  3740.           STATUS = STZONE(6, 0, 0, SNAME, 5, 0, 0, DNAME)
  3741.  
  3742.  
  3743.           ■  Description
  3744.  
  3745.           The stzone function  sets the standard time  and daylight savings
  3746.           time offsets  from the calendar  clock and the  standard and day-
  3747.           light time  zone names or mnemonics.   Note that the  offsets are
  3748.           subtracted from the calendar  clock to get the local time.   Thus
  3749.           the standard time offset from UTC to EST is 5:0:0.
  3750.  
  3751.  
  3752.  
  3753.                                           55
  3754.  
  3755.  
  3756.  
  3757.  
  3758.  
  3759.  
  3760.  
  3761.  
  3762.  
  3763.  
  3764.  
  3765.  
  3766.           CLOCK Version 3.31                               February 4, 1993
  3767.  
  3768.  
  3769.           ■ Arguments         SHOUR:SMIN:SSEC
  3770.                                    is  the time difference between the cal-
  3771.                                    endar clock and local standard time.  It
  3772.                                    may be a positive of negative value.  If
  3773.                                    negative, all three values must be nega-
  3774.                                    tive.
  3775.  
  3776.                               SNAME
  3777.                                    is the standard  time zone name or  mne-
  3778.                                    monic.   It must be  a 32-character LJSF
  3779.                                    character  string.   As  with  all other
  3780.                                    character  strings used  by  these func-
  3781.                                    tions,  there  is  no  terminating  NULL
  3782.                                    character as  is usual in C.   The other
  3783.                                    languages  do  not  readily  handle NULL
  3784.                                    terminated strings.   In  C applications
  3785.                                    you may  define the  character array  to
  3786.                                    contain  33  characters,  but  you  must
  3787.                                    ensure that the  NULL character does not
  3788.                                    occur in the first 32 characters.
  3789.  
  3790.  
  3791.                               DHOUR:DMIN:DSEC
  3792.                                    is the time difference  between the cal-
  3793.                                    endar clock  and local  daylight savings
  3794.                                    time.   Whether  the standard  offset or
  3795.                                    the daylight offset is currently used by
  3796.                                    CLOCK.SYS is  controlled by the  setting
  3797.                                    of the day_light mode bit (see stmode).
  3798.  
  3799.                               DNAME
  3800.                                    is the  daylight savings time  zone name
  3801.                                    or mnemonic.   It must be a 32-character
  3802.                                    LJSF character string.
  3803.  
  3804.  
  3805.           ■ Return Value
  3806.  
  3807.           If  the return  value is  zero, the  function succeeded.   If the
  3808.           return  value is non-zero, an error has occurred and _doserrno is
  3809.           set to the corresponding error code.  Possible values are:
  3810.  
  3811.  
  3812.  
  3813.  
  3814.  
  3815.  
  3816.  
  3817.  
  3818.  
  3819.                                           56
  3820.  
  3821.  
  3822.  
  3823.  
  3824.  
  3825.  
  3826.  
  3827.  
  3828.  
  3829.  
  3830.  
  3831.  
  3832.           CLOCK Version 3.31                               February 4, 1993
  3833.  
  3834.  
  3835.                0001h     Invalid  function.    This  should  indicate  that
  3836.                          CLOCK.SYS is not  installed.  It is the error that
  3837.                          the DOS clock device driver  would return since it
  3838.                          doesn't handle these functions.
  3839.  
  3840.                0005h     Access denied.  Indicates that DOS would not  open
  3841.                          a handle for read access.  You may not have enough
  3842.                          handles available.
  3843.  
  3844.  
  3845.                0006h     Invalid handle.  Should not happen.
  3846.  
  3847.                000Dh     Invalid data.  CLOCK.SYS reported a bad byte count
  3848.                          or otherwise  did not process  the request.   This
  3849.                          should not happen.
  3850.  
  3851.  
  3852.  
  3853.  
  3854.  
  3855.  
  3856.  
  3857.  
  3858.  
  3859.  
  3860.  
  3861.  
  3862.  
  3863.  
  3864.  
  3865.  
  3866.  
  3867.  
  3868.  
  3869.  
  3870.  
  3871.  
  3872.  
  3873.  
  3874.  
  3875.  
  3876.  
  3877.  
  3878.  
  3879.  
  3880.  
  3881.  
  3882.  
  3883.  
  3884.  
  3885.                                           57
  3886.  
  3887.  
  3888.  
  3889.  
  3890.  
  3891.  
  3892.  
  3893.  
  3894.  
  3895.  
  3896.  
  3897.  
  3898.           CLOCK Version 3.31                               February 4, 1993
  3899.  
  3900.  
  3901.           ■  Example
  3902.  
  3903.           #include <stdio.h>
  3904.             #include <ioctl.h>
  3905.  
  3906.  
  3907.             main()
  3908.  
  3909.             {
  3910.                   unsigned char sname[33] = "PST                             ";
  3911.                   unsigned char dname[33] = "PDT                             ";
  3912.  
  3913.                   int shour = 8;
  3914.                   int smin = 0;
  3915.                   int ssec = 0;
  3916.                   int dhour = 7;
  3917.                   int dmin = 0;
  3918.                   int dsec = 0;
  3919.  
  3920.                   struct CLOCK_DATA cdata;
  3921.  
  3922.             /* Get current status.                                    */
  3923.  
  3924.                   clksta(&cdata);
  3925.  
  3926.  
  3927.             /* Set time zone to U.S. Pacific time.  */
  3928.  
  3929.                   stzone(&shour,&smin, &ssec,sname,&dhour, &dmin,&dsec,dname);
  3930.  
  3931.             /* Select daylight savings time.  */
  3932.  
  3933.  
  3934.                   cdata.mode.day_light = 1;
  3935.                   stmode(&cdata.mode);
  3936.             }
  3937.  
  3938.  
  3939.  
  3940.  
  3941.  
  3942.  
  3943.  
  3944.  
  3945.  
  3946.  
  3947.  
  3948.  
  3949.  
  3950.  
  3951.                                           58
  3952.  
  3953.  
  3954.  
  3955.  
  3956.  
  3957.  
  3958.  
  3959.  
  3960.  
  3961.  
  3962.  
  3963.  
  3964.           CLOCK Version 3.31                               February 4, 1993
  3965.  
  3966.  
  3967.           5.9  tdisp
  3968.  
  3969.           ■  Summary
  3970.  
  3971.  
  3972.           C          
  3973.           -
  3974.  
  3975.           #include <ioctl.h>
  3976.  
  3977.           extern int pascal far tdisp(int *dispx, int *dispy, int *attr);
  3978.  
  3979.  
  3980.           BASIC          
  3981.           -----
  3982.  
  3983.           DECLARE FUNCTION TDISP%(DISPX%, DISPY%, ATTR%)
  3984.  
  3985.           STATUS% = TDISP(72, 0, &H79)
  3986.  
  3987.  
  3988.           FORTRAN          
  3989.           -------
  3990.  
  3991.           INTEGER*2 TDISP, STATUS
  3992.  
  3993.           STATUS = TDISP(0, 72, 0x79)
  3994.  
  3995.  
  3996.           ■  Description
  3997.  
  3998.           The  tdisp function sets  the coordinates  and attribute  for the
  3999.           continuous  time display.    tdisp  does not  start  or stop  the
  4000.           continuous  display nor does it set  the 12-hour or 24-hour mode.
  4001.           Those are all provided by the stmode function.
  4002.  
  4003.           ■ Arguments         DISPX
  4004.                                    is the x  (horizontal) cursor coordinate
  4005.                                    for  the continuous  time display.   The
  4006.                                    rightmost character on a line is at x=0.
  4007.                                    Be sure to leave enough space at the end
  4008.                                    of the line to accommodate the entire 8-
  4009.                                    chararacter time display.   For example,
  4010.                                    x=72 is the last position  to specify on
  4011.                                    an 80-character line.
  4012.  
  4013.                                                                            
  4014.  
  4015.  
  4016.  
  4017.                                           59
  4018.  
  4019.  
  4020.  
  4021.  
  4022.  
  4023.  
  4024.  
  4025.  
  4026.  
  4027.  
  4028.  
  4029.  
  4030.           CLOCK Version 3.31                               February 4, 1993
  4031.  
  4032.  
  4033.                               DISPY
  4034.                                    is  the y  (vertical)  cursor coordinate
  4035.                                    for the  continuous time  display.   The
  4036.                                    top line on the display is y=0.
  4037.  
  4038.                               ATTR
  4039.                                    is  the display attribute to use for the
  4040.                                    continuous time display.  ATTR is usual-
  4041.                                    ly  expressed  as two  hex digits.   The
  4042.                                    first (high-order)  digit  is the  back-
  4043.                                    ground  color (0  to 7)  and  the second
  4044.                                    digit is the text or foreground color (0
  4045.                                    to  F).  For  example, 0A  would display
  4046.                                    bright  green letters  on a  black back-
  4047.                                    ground.   Background  colors usually  do
  4048.                                    not  include  the  bright  colors.   The
  4049.                                    color numbers are:
  4050.  
  4051.                                         0    Black
  4052.                                         1    Blue
  4053.                                         2    Green                         
  4054.                                         3    Cyan
  4055.                                         4    Red
  4056.                                         5    Magenta
  4057.                                         6    Brown
  4058.                                         7    White
  4059.                                         8    Grey                          
  4060.                                         9    Bright blue
  4061.                                         A    Bright green
  4062.                                         B    Brigth cyan
  4063.                                         C    Bright red
  4064.                                         D    Bright magenta
  4065.                                         E    Yellow                        
  4066.                                         F    Bright White
  4067.  
  4068.           ■ Return Value
  4069.  
  4070.           If the  return value  is zero,  the function  succeeded.   If the
  4071.           return value is non-zero, an  error has occurred and _doserrno is
  4072.           set to the corresponding error code.  Possible values are:
  4073.  
  4074.                                                                             
  4075.  
  4076.  
  4077.  
  4078.  
  4079.  
  4080.  
  4081.  
  4082.  
  4083.                                           60
  4084.  
  4085.  
  4086.  
  4087.  
  4088.  
  4089.  
  4090.  
  4091.  
  4092.  
  4093.  
  4094.  
  4095.  
  4096.           CLOCK Version 3.31                               February 4, 1993
  4097.  
  4098.  
  4099.                0001h     Invalid  function.    This  should  indicate  that
  4100.                          CLOCK.SYS is not  installed.  It is the error that
  4101.                          the DOS clock device driver  would return since it
  4102.                          doesn't handle these functions.
  4103.  
  4104.                0005h     Access denied.  Indicates that DOS would not  open
  4105.                          a handle for read access.  You may not have enough
  4106.                          handles available.
  4107.  
  4108.  
  4109.                0006h     Invalid handle.  Should not happen.
  4110.  
  4111.                000Dh     Invalid data.  CLOCK.SYS reported a bad byte count
  4112.                          or otherwise  did not process  the request.   This
  4113.                          should not happen.
  4114.  
  4115.  
  4116.  
  4117.  
  4118.  
  4119.  
  4120.  
  4121.  
  4122.  
  4123.  
  4124.  
  4125.  
  4126.  
  4127.  
  4128.  
  4129.  
  4130.  
  4131.  
  4132.  
  4133.  
  4134.  
  4135.  
  4136.  
  4137.  
  4138.  
  4139.  
  4140.  
  4141.  
  4142.  
  4143.  
  4144.  
  4145.  
  4146.  
  4147.  
  4148.  
  4149.                                           61
  4150.  
  4151.  
  4152.  
  4153.  
  4154.  
  4155.  
  4156.  
  4157.  
  4158.  
  4159.  
  4160.  
  4161.  
  4162.           CLOCK Version 3.31                               February 4, 1993
  4163.  
  4164.  
  4165.           ■  Example
  4166.  
  4167.           #include <stdio.h>
  4168.             #include <ioctl.h>
  4169.  
  4170.  
  4171.             main()
  4172.  
  4173.             {
  4174.                   struct CLOCK_DATA cdata;
  4175.                   int dispx = 72;                                          
  4176.                   int dispy = 0;
  4177.                   int attr = 0x79;
  4178.  
  4179.             /* Get current CLOCK.SYS modes.  */
  4180.  
  4181.                   clksta(&cdata);
  4182.  
  4183.  
  4184.             /* Turn on 12-hour display at end of top line of screen. 
  4185.                Use bright blue text on a white backgroun.  */
  4186.  
  4187.                   tdisp(&dispx, &dispy, &attr);
  4188.                   cdata.mode.disp_tim = 1;                                 
  4189.                   cdata.mode.disp_24 = 0;
  4190.                   stmode(&cdata.mode);
  4191.  
  4192.             }
  4193.  
  4194.  
  4195.  
  4196.  
  4197.  
  4198.  
  4199.  
  4200.  
  4201.  
  4202.  
  4203.  
  4204.  
  4205.  
  4206.  
  4207.  
  4208.  
  4209.  
  4210.  
  4211.  
  4212.  
  4213.  
  4214.  
  4215.                                           62
  4216.  
  4217.  
  4218.  
  4219.  
  4220.  
  4221.  
  4222.  
  4223.  
  4224.  
  4225.  
  4226.  
  4227.  
  4228.           CLOCK Version 3.31                               February 4, 1993
  4229.  
  4230.  
  4231.           6  CLOCK.SYS - ASSEMBLY LANGUAGE API
  4232.  
  4233.           CLOCK.SYS has a  couple of additional APIs  (Application Program-
  4234.           ming Interfaces) that  are not present  in the normal  DOS CLOCK$
  4235.           device driver.   These interfaces are  provided by the  DOS IOCTL
  4236.           (Input/Output  of ConTroL  data) functions.   The  Output Control
  4237.           Data to  Character Device function  is used to  set new operating
  4238.           values for CLOCK.SYS  for the C=, D=, R=,  TZ=, and /P functions.
  4239.           The Input Control Data from  Character Device function is used to
  4240.           get the current status  and the date and  time from the  calendar
  4241.           clock.
  4242.  
  4243.  
  4244.           6.1  Opening the CLOCK$ Device
  4245.  
  4246.  
  4247.           In order  to use  the additional APIs  provided by  CLOCK.SYS you
  4248.           must  open a handle  to the  CLOCK$ device driver.   You  do this
  4249.           using  the DOS  INT  21H Open  File  with Handle  (3DH)  function
  4250.           specifying read-write access.  You  then use the handle to invoke
  4251.           the other functions.  Sample assembly language is:
  4252.  
  4253.                MOV  AX,3D00H            ; Open with read and write access  
  4254.                MOV  DX,OFFSET filename  ; Pointer to "CLOCK$" ASCIIZ string
  4255.                                         ; DS:DX must point to the string
  4256.                INT  21H                 ; Call DOS function handler
  4257.           ;    AX contains the handle on return if carry flag is not set.
  4258.  
  4259.  
  4260.  
  4261.           6.2  Sending New Values to CLOCK.SYS
  4262.  
  4263.           To change the  state of CLOCK.SYS, you use  the Send Control Data
  4264.           to  Character Device  (4403H) DOS  function.   You  send data  to
  4265.           specify the connection type, modes, time zone offsets and  names,
  4266.           restrictions, continuous display information,  and password.  You
  4267.           may send  any combination of these in any order.  You must always
  4268.           send  the current  password as the  first 8  bytes.   If password
  4269.           checking  is not  enabled, it  doesn't  matter what  the 8  bytes
  4270.           contain, but you must still send the 8 bytes.
  4271.  
  4272.           The  data stream  that  you  send to  CLOCK.SYS  consists of  the
  4273.           current password followed by a selection index, the data for that
  4274.           selection, another selection index, its data, and so on.
  4275.  
  4276.  
  4277.  
  4278.  
  4279.  
  4280.  
  4281.                                           63
  4282.  
  4283.  
  4284.  
  4285.  
  4286.  
  4287.  
  4288.  
  4289.  
  4290.  
  4291.  
  4292.  
  4293.  
  4294.           CLOCK Version 3.31                               February 4, 1993
  4295.  
  4296.  
  4297.           The selection  indices and the  data stream associated  with each
  4298.           one are:
  4299.  
  4300.           INDEX     DATA ITEMS     COMMENTS          
  4301.           -----     ----------     --------
  4302.  
  4303.           1         connected      two  byte   integer  (0 : C=D,  1 : C=W,
  4304.                                    2 : C=R, 3 : C=A)
  4305.  
  4306.           2         mode           two byte integer  (see stmode for a  de-
  4307.                                    scription of the bits)
  4308.  
  4309.           3         standard       time_zone structure for standard time
  4310.                     daylight       time_zone structure for daylight time
  4311.  
  4312.           4         rules          limits structure
  4313.  
  4314.  
  4315.           5         display        disp structure
  4316.  
  4317.           6         password       8 bytes LJSF of new password
  4318.  
  4319.  
  4320.  
  4321.  
  4322.  
  4323.  
  4324.  
  4325.  
  4326.  
  4327.  
  4328.  
  4329.  
  4330.  
  4331.  
  4332.  
  4333.  
  4334.  
  4335.  
  4336.  
  4337.  
  4338.  
  4339.  
  4340.  
  4341.  
  4342.  
  4343.  
  4344.  
  4345.  
  4346.  
  4347.                                           64
  4348.  
  4349.  
  4350.  
  4351.  
  4352.  
  4353.  
  4354.  
  4355.  
  4356.  
  4357.  
  4358.  
  4359.  
  4360.           CLOCK Version 3.31                               February 4, 1993
  4361.  
  4362.  
  4363.           Sample assembly language to send new information to CLOCK.SYS:
  4364.  
  4365.           curpw     DB   8 dup(?)       ; Current password                 
  4366.                     DW   1              ; Change connection
  4367.                     DW   2              ;  to C=R
  4368.                     DW   4              ; Change limits
  4369.                     DW   0,0,2,1,0,0    ;  to R=B-::2,F+1
  4370.                     DW   6              ; Set new password
  4371.                     DB   "MyPasswd"     ;  to MyPasswd (case is important) 
  4372.                     DW   2              ; Change modes
  4373.                     DW   0D000H         ;  to enable limits and password
  4374.                                         ;  also sets standard time and 
  4375.                                         ;  no display
  4376.           count     equ $-curpw         ; Length to send
  4377.                     ...
  4378.                     MOV  AX,4403H       ; Send control data function
  4379.                     MOV  BX,handle      ; Value returned from open
  4380.                     MOV  CX,count       ; Value = number of bytes to send
  4381.                     MOV  DX,OFFSET curpw ; Location of bytes to be sent
  4382.                                         ; DS:DX must point to the buffer
  4383.                     INT  21H            ;
  4384.  
  4385.           ; OK if carry not set.  CX will equal bytes actually taken.
  4386.  
  4387.  
  4388.           6.3  Getting Current Status of CLOCK.SYS
  4389.  
  4390.           To get the  current status and time, you use  the Receive Control
  4391.           Data from Character Device (4402H) function.  You can read all of
  4392.           the CLOCK_DATA  structure or  any smaller amount  of it  that you
  4393.           need, but you can only read starting at the beginning
  4394.  
  4395.           Sample assembly language for reading the clock status is:        
  4396.  
  4397.                MOV  AX,440CH            ; Read control data function
  4398.                MOV  BX,handle           ; Value returned from open
  4399.                MOV  CX,count            ; Number of bytes to read
  4400.                MOV  DX,OFFSET buffer    ; Location to store the data
  4401.                                         ; DS:DX must point to the buffer
  4402.                INT  21H                 ; Call DOS
  4403.  
  4404.           ; Data returned if carry not set.
  4405.           ; CX will contain the actual number of bytes transferred.
  4406.  
  4407.  
  4408.  
  4409.  
  4410.  
  4411.  
  4412.  
  4413.                                           65
  4414.  
  4415.  
  4416.  
  4417.  
  4418.  
  4419.  
  4420.  
  4421.  
  4422.  
  4423.  
  4424.  
  4425.  
  4426.           CLOCK Version 3.31                               February 4, 1993
  4427.  
  4428.  
  4429.           APPENDIX A:  DEFINITION OF SHAREWARE
  4430.  
  4431.           Shareware  distribution  gives  users a  chance  to  try software
  4432.           before  buying it.  If you try  a Shareware  program and continue
  4433.           using  it, you  are  expected  to register.  Individual  programs
  4434.           differ  on  details --  some  request  registration while  others
  4435.           require it, some specify a maximum trial period.   With registra-
  4436.           tion,  you get anything from  the simple right  to continue using
  4437.           the software to an updated program with printed manual.
  4438.  
  4439.  
  4440.           Copyright laws apply  to both Shareware and  commercial software,
  4441.           and the copyright  holder retains all rights, with a few specific
  4442.           exceptions  as stated below.  Shareware authors  are accomplished
  4443.           programmers, just  like commercial authors, and  the programs are
  4444.           of comparable  quality. (In both  cases, there are  good programs
  4445.           and bad ones!) The main difference  is in the method of distribu-
  4446.           tion.  The  author  specifically grants  the  right  to copy  and
  4447.           distribute the software, either to all and sundry or to a specif-
  4448.           ic group. For  example, some  authors require written  permission
  4449.           before a commercial disk vendor may copy their Shareware.
  4450.  
  4451.  
  4452.           Shareware  is a distribution method, not  a type of software. You
  4453.           should  find software  that  suits  your  needs  and  pocketbook,
  4454.           whether it's  commercial or Shareware. The Shareware system makes
  4455.           fitting your  needs easier, because you  can try before  you buy.
  4456.           And because the  overhead is low, prices are  low also. Shareware
  4457.           has the  ultimate money-back guarantee  -- if  you don't use  the
  4458.           product, you don't pay for it.
  4459.  
  4460.           DISCLAIMER - AGREEMENT
  4461.  
  4462.           Users  of CLOCK must accept this  disclaimer of warranty:  "CLOCK
  4463.           is supplied  as is.   The  author disclaims  all warranties,  ex-
  4464.           pressed or implied, including, without limitation, the warranties
  4465.           of merchantability  and of fitness for  any purpose.   The author
  4466.           assumes no liability for damages, direct  or consequential, which
  4467.           may result from the use of CLOCK."
  4468.  
  4469.           CLOCK is a  "shareware program" and is  provided at no charge  to
  4470.           the  user for  evaluation.   Feel  free  to  share it  with  your
  4471.           friends, but please  do not give  it away altered  or as part  of
  4472.  
  4473.  
  4474.  
  4475.  
  4476.  
  4477.  
  4478.  
  4479.                                           66
  4480.  
  4481.  
  4482.  
  4483.  
  4484.  
  4485.  
  4486.  
  4487.  
  4488.  
  4489.  
  4490.  
  4491.  
  4492.           CLOCK Version 3.31                               February 4, 1993
  4493.  
  4494.  
  4495.           another system.   The essence of "user-supported"  software is to
  4496.           provide  personal  computer users  with quality  software without
  4497.           high prices,  and yet  to provide  incentive  for programmers  to
  4498.           continue to  develop new  products.   If  you find  this  program
  4499.           useful and  find that  you are  using CLOCK  and continue  to use
  4500.           CLOCK after a reasonable trial  period, you must make a registra-
  4501.           tion payment of $10 to Ronald Q. Smith.  The $10 registration fee
  4502.           will license  one copy  for use on  any one  computer at any  one
  4503.           time.  For a registration fee of $25, I will immediately send you
  4504.           the  latest version of  CLOCK including the  source code and this
  4505.           document as a WordPerfect 5.1 file.   You may use the source code
  4506.           for your own  maintenance of CLOCK or as a  learning tool for any
  4507.           software that you develop.   You may not  use all or part  of the
  4508.           source code in any software that you develop or release to others
  4509.           without the permission of Ronald Q. Smith.
  4510.  
  4511.  
  4512.           You must treat  this software just  like a book.   An example  is
  4513.           that this software may be used by any number of people and may be
  4514.           freely moved  from one computer  location to another, so  long as
  4515.           there is  no possibility of it  being used at  one location while
  4516.           it's being used at another.  Just as a book cannot be read by two
  4517.           different persons at the same time.
  4518.  
  4519.           Commercial users of CLOCK must register and pay for  their copies
  4520.           of CLOCK  within 30 days of  first use or their  license is with-
  4521.           drawn.    Site-License arrangements  may  be  made by  contacting
  4522.           Ronald Q. Smith.
  4523.  
  4524.  
  4525.           Anyone distributing CLOCK for any kind of remuneration must first
  4526.           contact Ronald Q. Smith at the address below for authorization.
  4527.  
  4528.           You are encouraged to  pass a copy of CLOCK along to your friends
  4529.           for evaluation.  Please encourage them  to register their copy if
  4530.           they find  that  they can  use  it.   All registered  users  will
  4531.           receive a copy of the latest version of the CLOCK system.
  4532.  
  4533.           Send the fees and any inquiries to:
  4534.  
  4535.                          Ronald Q. Smith                                   
  4536.                          11 Black Oak Road
  4537.                          North Oaks, MN 55127-6204
  4538.  
  4539.  
  4540.  
  4541.  
  4542.  
  4543.  
  4544.  
  4545.                                           67
  4546.  
  4547.  
  4548.  
  4549.  
  4550.  
  4551.  
  4552.  
  4553.  
  4554.  
  4555.  
  4556.  
  4557.  
  4558.           CLOCK Version 3.31                               February 4, 1993
  4559.  
  4560.  
  4561.           You may also contact me via CompuServe mail at userid  71620,514.
  4562.           I will be  happy to respond  to any problems and  suggestions for
  4563.           future capabilities.
  4564.  
  4565.  
  4566.           You may register CLOCK through the CompuServe Shareware Registra-
  4567.           tion program.  CLOCK.SYS is found under registration ID 104.  The
  4568.           fee  for registering through  CompuServe is  $12 (to  cover their
  4569.           charge) and will be added directly to your CompuServe bill.
  4570.  
  4571.  
  4572.  
  4573.  
  4574.  
  4575.  
  4576.  
  4577.  
  4578.  
  4579.  
  4580.  
  4581.  
  4582.  
  4583.  
  4584.  
  4585.  
  4586.  
  4587.  
  4588.  
  4589.  
  4590.  
  4591.  
  4592.  
  4593.  
  4594.  
  4595.  
  4596.  
  4597.  
  4598.  
  4599.  
  4600.  
  4601.  
  4602.  
  4603.  
  4604.  
  4605.  
  4606.  
  4607.  
  4608.  
  4609.  
  4610.  
  4611.                                           68
  4612.  
  4613.  
  4614.  
  4615.  
  4616.  
  4617.  
  4618.  
  4619.  
  4620.  
  4621.  
  4622.  
  4623.  
  4624.           CLOCK Version 3.31                               February 4, 1993
  4625.  
  4626.  
  4627.           APPENDIX B:  CLOCK TYPES                                         
  4628.  
  4629.  
  4630.           B.1  Type 0 - PC/AT
  4631.  
  4632.           IBM PC/AT and  all fully compatible  PCs.   Most versions of  DOS
  4633.           fully support  this clock  interface without  a separate  driver.
  4634.           Use CLOCK.SYS to provide support for CLK.EXE and CLKDEMO.EXE.  If
  4635.           you don't  need the  extra functions of  CLK, you  probably don't
  4636.           need CLOCK.SYS.  However,  there were a couple  of late 8088  PCs
  4637.           that adopted  the PC/AT  clock standard but  did not  provide the
  4638.           PC/AT recognition  sentinel.  DOS  will not  find the clock,  but
  4639.           CLOCK.SYS will.
  4640.  
  4641.           Amstrad PC1521DD systems use this type of clock.
  4642.  
  4643.                           
  4644.           Automatic  determination checks  location  F000:FFFE for  the hex
  4645.           value FC.
  4646.  
  4647.           BIOS calls are used  to read and write the clock values which are
  4648.           usually  stored in  the CMOS  RAM along with  other configuration
  4649.           information.  The primary interfaces are:
  4650.                           
  4651.                Get Date: MOV  AH,4
  4652.                          INT  1AH
  4653.                               Returns the year in  CX and month and  day in
  4654.                               DX in BCD  format (e.g., a hex  display would
  4655.                               show:  CX=1991, DX=1009 for October 9, 1991).
  4656.  
  4657.                Set Date: MOV  AH,5
  4658.                               Load CX and DX as above for Get Date
  4659.                          INT  1AH
  4660.  
  4661.  
  4662.                Get Time: MOV  AH,2
  4663.                          INT  1AH
  4664.                               Returns hours  and minutes in CX  and seconds
  4665.                               in DH in BCD format.   May also return 100ths
  4666.                               of seconds in DL (e.g., CX=2359, DX=5900  for
  4667.                               1 second before midnight).
  4668.  
  4669.  
  4670.  
  4671.  
  4672.  
  4673.  
  4674.  
  4675.  
  4676.  
  4677.                                           69
  4678.  
  4679.  
  4680.  
  4681.  
  4682.  
  4683.  
  4684.  
  4685.  
  4686.  
  4687.  
  4688.  
  4689.  
  4690.           CLOCK Version 3.31                               February 4, 1993
  4691.  
  4692.  
  4693.                Set Time: MOV  AH,3
  4694.                               Load CX and DX as for Get Time
  4695.                          INT  1AH
  4696.  
  4697.  
  4698.  
  4699.  
  4700.           B.2  Type 1 - Zenith Z-18x portables, Supersport 20
  4701.  
  4702.           Automatic determination checks  location F000:FFFA  for the  two-
  4703.           byte hex value 4D32 ("M2").
  4704.  
  4705.           BIOS calls are used to read and write the clock.
  4706.  
  4707.                Get Date: MOV  AH,2
  4708.                          INT  1AH                                          
  4709.                               Returns CX=year (1980  - 2079) in binary  and
  4710.                               DH=month, DL=day.  All  values are binary.  A
  4711.                               hex display of the above date would look like
  4712.                               CX=7C7, DX=A09.
  4713.  
  4714.                Set Date: MOV  AH,3                                         
  4715.                               Load CX and DX as for Get Date.
  4716.                          INT  1AH
  4717.  
  4718.                Get Time: MOV  AH,4
  4719.                          INT  1AH
  4720.                               Returns  CH=hours, CL=minutes, DH=seconds.  A
  4721.                               hex display would show: CX=173B, DX=3B00.
  4722.  
  4723.                Set Time: MOV  AH,5
  4724.                               Load CX and DX as for Get Time.
  4725.                          INT  1AH
  4726.  
  4727.  
  4728.  
  4729.           B.3  Type 2 - Various Zenith Data System PCs.
  4730.  
  4731.           Automatic  determination  looks  at  location F000:800A  for  the
  4732.           pattern 00,F0,"ZDS".
  4733.  
  4734.  
  4735.  
  4736.  
  4737.  
  4738.  
  4739.  
  4740.  
  4741.  
  4742.  
  4743.                                           70
  4744.  
  4745.  
  4746.  
  4747.  
  4748.  
  4749.  
  4750.  
  4751.  
  4752.  
  4753.  
  4754.  
  4755.  
  4756.           CLOCK Version 3.31                               February 4, 1993
  4757.  
  4758.  
  4759.                Get Date: MOV  AH,2AH
  4760.                          INT  1AH
  4761.                               Returns CX and DX as for type 1.
  4762.  
  4763.  
  4764.                Set Date: MOV  AH,2BH
  4765.                               Load CX and DX as for type 1.
  4766.                          INT  1AH
  4767.  
  4768.                Get Time: MOV  AH,2CH                                       
  4769.                          INT  1AH
  4770.                               Returns CX and DX as for type 1.
  4771.  
  4772.                Set Time: MOV  AH,2DH
  4773.                               Load CX and DX as for type 1.
  4774.                          INT  1AH
  4775.  
  4776.  
  4777.  
  4778.           B.4  Type 3 - Memory-Mapped Clocks
  4779.  
  4780.           Memory-mapped  clock used  on some  Zenith Data  Systems  PCs and
  4781.           other similar clocks including many slot-less or  no-slot clocks.
  4782.           The  SMT (Systems  Manufacturing Technology)  No-Slot clocks  are
  4783.           supported by this type.
  4784.  
  4785.           Automatic determination  is to  attempt to  read the  clock.   If
  4786.           values other than all 0FFH or 0 are obtained, this  clock type is
  4787.           chosen.  All known segments and offsets are tried.
  4788.  
  4789.  
  4790.           Several different  memory mapping  approaches are  used and  many
  4791.           different address  possibilities are  supported.   In  general  a
  4792.           segment address in the ROM region (C800H through FFFFH) is  used.
  4793.           Offsets from that  segment address are used  to read bits,  write
  4794.           zero bits, and write  one bits.  Documentation may  specify those
  4795.           segments  and addresses in  several forms.   For example, segment
  4796.           F000 with offset F002 is the same as segment FF00 with offset 2.
  4797.  
  4798.           Each memory reference  reads or writes a single bit.  Read opera-
  4799.           tions  are  used for  all  references with  separate  offsets for
  4800.           reading a bit, writing a zero bit, and writing a one bit.
  4801.  
  4802.  
  4803.           Clock segments and addresses currently probed include:
  4804.  
  4805.  
  4806.  
  4807.  
  4808.  
  4809.                                           71
  4810.  
  4811.  
  4812.  
  4813.  
  4814.  
  4815.  
  4816.  
  4817.  
  4818.  
  4819.  
  4820.  
  4821.  
  4822.           CLOCK Version 3.31                               February 4, 1993
  4823.  
  4824.  
  4825.  
  4826.             SEGMENT   WRITE0   WRITE1   READ    DECR     LAST     VENDOR
  4827.  
  4828.  
  4829.              F000       F002     F003    F004    0000    F000    (Zenith)
  4830.  
  4831.              FE00       2        3       5       0080    C800    SMT
  4832.  
  4833.              FE00       0        2       8       0080    C800    SMT
  4834.  
  4835.           Multiple  address combinations may  be tried for  each clock pat-
  4836.           tern.   The DECR  value is subtracted from  the SEGMENT value for
  4837.           another attempt  at probing until  the value  equals LAST.   Note
  4838.           that  like the  SEGMENT address,  DECR and LAST  are in  units of
  4839.           paragraphs (16-bytes).   Thus DECR of 80 is equivalent to 800H or
  4840.           2048 bytes.
  4841.  
  4842.           When  the addresses used by  a memory-mapped clock are determined
  4843.           by probing, the segment  and read address  is displayed.  As  the
  4844.           read address  varies  the most  from  one clock  manufacturer  to
  4845.           another it is a good indication of the type of clock found.
  4846.  
  4847.           Data is stored in BCD in bytes that you construct by  shifting in
  4848.           the bits.  The most important data bytes are: 
  4849.  
  4850.                0 = Hundredths of seconds
  4851.                1 = Seconds
  4852.                2 = Minutes
  4853.                3 = hours
  4854.                5 = days
  4855.                6 = months
  4856.                7 = years mod 1980
  4857.  
  4858.  
  4859.  
  4860.           B.5  Type 4 - Direct Register I/O Bus Clock
  4861.  
  4862.           Many  add-in clocks on  expansion boards use  this type of clock.
  4863.           Some built-in clocks in  PCs are also  accessed similarly.   This
  4864.           clock was  used on many AST Research I/O boards for 8088 PCs such
  4865.           as the Six-Pack  Plus, IO  Plus, etc.   Also used  on some  Tandy
  4866.           systems (e.g., 1200HD) and the Vendex Turbo-888-XT.
  4867.  
  4868.  
  4869.  
  4870.  
  4871.  
  4872.  
  4873.  
  4874.  
  4875.                                           72
  4876.  
  4877.  
  4878.  
  4879.  
  4880.  
  4881.  
  4882.  
  4883.  
  4884.  
  4885.  
  4886.  
  4887.  
  4888.           CLOCK Version 3.31                               February 4, 1993
  4889.  
  4890.  
  4891.           Automatic determination is to attempt to read, complement, write,
  4892.           re-read, and re-complement  one of the registers.   If the  first
  4893.           value read  and the re-complemented  second value are  equal, the
  4894.           register exists and is presumed to be the clock.
  4895.  
  4896.           See also the description for  types 6 and 7.  If you  aren't sure
  4897.           which variant you have, specify type 8 and automatic probing will
  4898.           determine if it is  really a type 4, 6,  or 7.  For  the greatest
  4899.           chance of detecting  the correct clock type, supply  the base I/O
  4900.           address if at all possible.
  4901.  
  4902.           NOTE:  If the clock is not correctly  initialized (e.g., you have
  4903.           just  replaced the battery), CLOCK.SYS must initialize it so that
  4904.           the counters  will start working.  CLOCK.SYS  determines that the
  4905.           clock has been previously initialized by looking at  register 14H
  4906.           (see B below).  If register B contains  the value 0DEH, the clock
  4907.           is presumed to be initialized.  If  not, CLOCK.SYS will clear all
  4908.           the registers to zero and start the counters running.  While this
  4909.           form  of  checking  for initialization  was  commonly  used, your
  4910.           previous software may have used  a different method.  If  so, the
  4911.           first time  you run CLOCK.SYS  your date and  time may be  set to
  4912.           zero  (1980-1-1 00:00:00).  If that  happens, just enter the date
  4913.           and time.  It should work OK after that without resetting to zero
  4914.           on further boots.
  4915.  
  4916.           Each clock register is implemented as a separate I/O register ad-
  4917.           dress.   Clock base I/O addresses  of 240H, 2C0H, 300H,  and 340H
  4918.           are supported by automatic probing.  Similar clocks at other base
  4919.           I/O addresses  are supported  by specifying type  4 and  the base
  4920.           address. The address range  used is the  base plus 0 through  1FH
  4921.           (e.g., 2C0H through 2DFH).
  4922.                           
  4923.  
  4924.  
  4925.  
  4926.  
  4927.  
  4928.  
  4929.  
  4930.  
  4931.  
  4932.  
  4933.  
  4934.  
  4935.  
  4936.  
  4937.  
  4938.  
  4939.  
  4940.  
  4941.                                           73
  4942.  
  4943.  
  4944.  
  4945.  
  4946.  
  4947.  
  4948.  
  4949.  
  4950.  
  4951.  
  4952.  
  4953.  
  4954.           CLOCK Version 3.31                               February 4, 1993
  4955.  
  4956.  
  4957.           Important registers are (using 2C0 as the example):
  4958.                           
  4959.                2C1  =  100ths of seconds                                   
  4960.                2C2  =  seconds 
  4961.                2C3  =  minutes 
  4962.                2C4  =  hours 
  4963.                2C6  =  days
  4964.                2C7  =  months
  4965.                2C9  =  month last time clock was read/set                  
  4966.                2CA  =  years
  4967.                2CB  =  initialized flag (0DEH if initialized)
  4968.                2D4  =  Status
  4969.                               
  4970.           All values are in BCD.  That means that each register consists of
  4971.           two 4-bit nybbles (a nybble is to a nibble as a byte is to a bite
  4972.           - I haven't seen this  used recently, but as a bit of trivia, the
  4973.           first IBM 360 principles of operation manuals used  that term and
  4974.           that spelling -  at least in a  draft copy that we got  in 1965).
  4975.           Each nybble contains  one decimal digit of the  value.  Years are
  4976.           mod 1980 (i.e., 0 means 1980, 99 means 2079).
  4977.  
  4978.  
  4979.           Since these  clocks do not keep  the year and do  not handle leap
  4980.           years for you, CLOCK.SYS does the necessary calculations to  keep
  4981.           the  year correctly  maintained and to  adjust the  date for leap
  4982.           days.   The  clocks do  provide a couple  of memory  locations in
  4983.           which CLOCK.SYS maintains  the year and previous month.   As long
  4984.           as you boot your system before  a full year has passed, CLOCK.SYS
  4985.           will correctly maintain the date.
  4986.  
  4987.  
  4988.           B.6  Type 5 - Mitsubishi 8088 PCs
  4989.  
  4990.           These were sold by Sperry as the PC-1 and  PC/HT, by Leading Edge
  4991.           as the Model D, by Mitsubishi, and others.
  4992.  
  4993.           Automatic determination checks location  F000:FFB3 for the string
  4994.           "MITSUBISHI".  Later Mitsubishi PCs  which used a different clock
  4995.           had  the same string at a different  location.  We hope all early
  4996.           versions had it at this location.
  4997.  
  4998.  
  4999.  
  5000.  
  5001.  
  5002.  
  5003.  
  5004.  
  5005.  
  5006.  
  5007.                                           74
  5008.  
  5009.  
  5010.  
  5011.  
  5012.  
  5013.  
  5014.  
  5015.  
  5016.  
  5017.  
  5018.  
  5019.  
  5020.           CLOCK Version 3.31                               February 4, 1993
  5021.  
  5022.  
  5023.           BIOS functions are used to access the clock.
  5024.  
  5025.                Get Date: MOV  AH,4                                         
  5026.                          INT  1AH
  5027.                               Returns  CL=year  mod  1980,  DH=month,   and
  5028.                               DL=day all  in binary.  Also  sets AL=0FFH if
  5029.                               the clock is  busy and the request  should be
  5030.                               retried.
  5031.  
  5032.  
  5033.                Set Date: MOV  AH,5
  5034.                               Load CL, DX as for Get Date.
  5035.                          INT  1AH
  5036.                               Returns AL=0FFH if busy.
  5037.  
  5038.                Get Time: MOV  AH,2                                         
  5039.                          INT  1AH
  5040.                               Returns  CH=hour,  CL=minute, DH=second,  and
  5041.                               AL=status.  AL=0FFH means  busy.  AL=0  means
  5042.                               24-hour mode.   AL=1 means AM and  AL=3 means
  5043.                               PM.
  5044.  
  5045.  
  5046.                Set Time: MOV  AH,3
  5047.                               Load AL, CX, DH as for Get Time.
  5048.                          INT  1AH
  5049.                               Returns AL=0FFH if busy.
  5050.  
  5051.           NOTE:  Some early Mitsubishi PCs came with fixed disk controllers
  5052.           that were not DOS compatible.  In addition to the clock modifica-
  5053.           tions, the DOS for those systems also handled the disk controller
  5054.           variant.  If  you have such a PC, CLOCK.SYS  is not sufficient to
  5055.           enable you to  go above DOS  level 3.2.   You will  also need  to
  5056.           replace your fixed  disk controller.  I strongly suggest that you
  5057.           create a boot floppy for your current DOS level before you try to
  5058.           install your new DOS level.  Then boot your new DOS from a floppy
  5059.           disk, do SYS C: and copy COMMAND.COM to C:, then try a disk boot.
  5060.           If the disk boot fails, boot the floppy you just created and do a
  5061.           SYS C:  and copy COMMAND.COM to  C: to restore your  old DOS ver-
  5062.           sion.  At that point, your best bet is to simply give up and stay
  5063.           with DOS 3.2. If you want to proceed, you must replace your fixed
  5064.           disk controller.
  5065.  
  5066.  
  5067.  
  5068.  
  5069.  
  5070.  
  5071.  
  5072.  
  5073.                                           75
  5074.  
  5075.  
  5076.  
  5077.  
  5078.  
  5079.  
  5080.  
  5081.  
  5082.  
  5083.  
  5084.  
  5085.  
  5086.           CLOCK Version 3.31                               February 4, 1993
  5087.  
  5088.  
  5089.           If  SYS C: gives  you an error  status that  indicates that there
  5090.           isn't room  for the new  DOS version  (very possible when  moving
  5091.           from 3.2 to 3.3 or above), you must backup your entire fixed disk
  5092.           and use FORMAT C:/S  to place the new version of DOS on the disk.
  5093.           While this is a hassle, at  least if your PC won't boot from  the
  5094.           disk, the fall-back approach is identical.  There will be room to
  5095.           put DOS 3.2 or earlier back on the fixed disk.
  5096.  
  5097.  
  5098.  
  5099.           B.7  Type 6 - Indirect Register I/O Bus Clock
  5100.  
  5101.           Used on AST Research boards and others.   Typically uses the same
  5102.           I/O  base address  as type 4.   However  the clock  registers are
  5103.           selected by sending the register address to the base  I/O address
  5104.           and then  reading or writing  data at the  base I/O address  + 1.
  5105.           The internal register numbers and  their contents are the same as
  5106.           for type 4.
  5107.  
  5108.           Automatic determination by probing the  address register.  If the
  5109.           low-order bit is one, it may be this type of clock or type 7.  We
  5110.           then look further to  determine if it is type  7.  If you  aren't
  5111.           sure which type of clock you have but believe it is type 4,  6 or
  5112.           7, specify type 8 and automatic probing will detect which variant
  5113.           it is.  If at all possible  specify the base I/O address as  that
  5114.           will increase  the likelihood  that the correct  determination is
  5115.           made.
  5116.  
  5117.  
  5118.           I/O  addresses  used are  (again using  2C0  as the  example base
  5119.           address):
  5120.  
  5121.                2C0    =  Address register.  Writing a value to this address
  5122.                          selects the internal register to read or write.
  5123.                2C1    =  Data register.   Reading or writing  this address,
  5124.                          reads  or writes the  internal register previously
  5125.                          selected by writing 2C0.
  5126.  
  5127.  
  5128.  
  5129.  
  5130.  
  5131.  
  5132.  
  5133.  
  5134.  
  5135.  
  5136.  
  5137.  
  5138.  
  5139.                                           76
  5140.  
  5141.  
  5142.  
  5143.  
  5144.  
  5145.  
  5146.  
  5147.  
  5148.  
  5149.  
  5150.  
  5151.  
  5152.           CLOCK Version 3.31                               February 4, 1993
  5153.  
  5154.  
  5155.           The internal register numbers are (the values to write to 2C0):
  5156.  
  5157.                 1  =  100ths of seconds                                    
  5158.                 2  =  seconds
  5159.                 3  =  minutes
  5160.                 4  =  hours
  5161.                 6  =  days
  5162.                 7  =  months
  5163.                 9  =  month last time date was read or written             
  5164.                 A  =  year
  5165.                 B  =  initialization flag
  5166.                14  =  status
  5167.                           
  5168.           Other processing is the same as type 4.
  5169.  
  5170.  
  5171.  
  5172.           B.8  Type 7 - Complex I/O Bus Clock
  5173.  
  5174.           Used on AST Research boards and others.  Typically uses the  same
  5175.           base I/O address as types  4 and 6.   Type 7 uses a more  complex
  5176.           register access sequence than type 6.  Type 7  can be detected by
  5177.           looking to see if the value in register D has bit 1 (value=2) set
  5178.           which type  6 will not.  If  you aren't sure which  type of clock
  5179.           you have  but believe it  is type 4, 6  or 7, specify  type 8 and
  5180.           automatic probing  will detect which  variant it is.   If at  all
  5181.           possible specify the  base I/O address as that  will increase the
  5182.           likelihood that the correct determination is made.
  5183.  
  5184.  
  5185.           The  base I/O address is used as an address register and the base
  5186.           + 1 as a data  register.  This is the  same as for clock type  6.
  5187.           However, the internal  registers and the form of  the commands is
  5188.           quite  different.   The primary difference  is that  the internal
  5189.           registers only hold  four bits of data each.   Thus each internal
  5190.           register represents a single decimal digit.
  5191.  
  5192.  
  5193.  
  5194.  
  5195.  
  5196.  
  5197.  
  5198.  
  5199.  
  5200.  
  5201.  
  5202.  
  5203.  
  5204.  
  5205.                                           77
  5206.  
  5207.  
  5208.  
  5209.  
  5210.  
  5211.  
  5212.  
  5213.  
  5214.  
  5215.  
  5216.  
  5217.  
  5218.           CLOCK Version 3.31                               February 4, 1993
  5219.  
  5220.  
  5221.           The I/O addresses are used as follows (using 2C0 as an example):
  5222.  
  5223.                2C0     = Address register.  The number  of an internal reg-
  5224.                          ister plus 80H  is written to this I/O  address to
  5225.                          select an internal register.
  5226.  
  5227.                2C1     = Data register.    Four bits  of data  are read  or
  5228.                          written  using  this I/O  address from  or  to the
  5229.                          internal register  previously selected  by writing
  5230.                          to 2C0.
  5231.  
  5232.           The internal registers are:
  5233.  
  5234.                0  =  Units digit of seconds
  5235.                1  =  Tens digit of seconds                                 
  5236.                2  =  Units digit of minutes
  5237.                3  =  Tens digit of minutes
  5238.                4  =  Units digit of hours
  5239.                5  =  Tens digit of hours
  5240.                6  =  Day of week
  5241.                7  =  Units digit of day of month                           
  5242.                8  =  Tens digit of day of month
  5243.                9  =  Units digit of month
  5244.                A  =  Tens digit of month
  5245.                B  =  Units digit of year
  5246.                C  =  Tens digit of year
  5247.                D  =  Function register                                     
  5248.                E  =  Function register
  5249.                F  =  Function register
  5250.  
  5251.  
  5252.           B.9  Type 8 - Generic I/O Bus Clock
  5253.  
  5254.  
  5255.           Type unknown.  Probe only for types 4,  6, 7, 9, and B.  Use type
  5256.           8 if you are sure that you have an I/O bus clock (i.e., the clock
  5257.           is on an add-in card) but aren't sure whether it is type 4, 6, 7,
  5258.           9, or B.  If at all possible,  supply the base I/O address of the
  5259.           clock as this will greatly increase the likelihood of the correct
  5260.           handling method being chosen.
  5261.  
  5262.  
  5263.  
  5264.  
  5265.  
  5266.  
  5267.  
  5268.  
  5269.  
  5270.  
  5271.                                           78
  5272.  
  5273.  
  5274.  
  5275.  
  5276.  
  5277.  
  5278.  
  5279.  
  5280.  
  5281.  
  5282.  
  5283.  
  5284.           CLOCK Version 3.31                               February 4, 1993
  5285.  
  5286.  
  5287.           B.10 Type 9 - Quadram I/O Bus Clock
  5288.  
  5289.           This  type  was  used by  Quadram  Corporation  on  the QuadCard,
  5290.           QuadCard II, and QuadCard 512+.  It may  have been used on others
  5291.           as well.
  5292.  
  5293.           Automatic determination checks to see that I/O registers exist at
  5294.           310H or 210H.
  5295.  
  5296.  
  5297.           This clock  used four I/O  control registers and  twelve internal
  5298.           registers.  The I/O registers (using 310H as the example) are:
  5299.  
  5300.                310  =  Data register (used to move data values)
  5301.                311  =  Address register (used to select internal register)
  5302.                312  =  Function register (Read, write, hold counter)       
  5303.                313  =  Control register (Enables read or write function)
  5304.  
  5305.           The internal registers are:
  5306.  
  5307.                 0 = Units digit of seconds                                 
  5308.                 1 = Tens digit of seconds
  5309.                 2 = Units digit of minutes
  5310.                 3 = Tens digit of minutes
  5311.                 4 = Units digit of hours
  5312.                 5 = Tens  digit of hours - Also uses bit 2 (=4) to indicate
  5313.                     PM if in  12-hour mode and bit 3 (=8) to select 24-hour
  5314.                     mode
  5315.                 6 = Day of week (we don't use this)
  5316.                 7 = Units digit of days
  5317.                 8 = Tens digit of  days - Also uses bit  3 (=8) to indicate
  5318.                     that this  is a  leap year.   This bit  must be  set by
  5319.                     software whenever there is less than 366 days until the
  5320.                     next leap day.  If you  do not boot within that period,
  5321.                     leap day will not be taken.
  5322.                 9 = Units digit of months
  5323.                10 = Tens digit of months
  5324.                11 = Units digit of year mod 1980
  5325.                12 = Tens digit of year mod 1980
  5326.  
  5327.  
  5328.           NOTE:  If you have this type  of clock, you can only set the time
  5329.           to the nearest minute.  Whenever the time is set, the seconds are
  5330.  
  5331.  
  5332.  
  5333.  
  5334.  
  5335.  
  5336.  
  5337.                                           79
  5338.  
  5339.  
  5340.  
  5341.  
  5342.  
  5343.  
  5344.  
  5345.  
  5346.  
  5347.  
  5348.  
  5349.  
  5350.           CLOCK Version 3.31                               February 4, 1993
  5351.  
  5352.  
  5353.           always  set to  zero.   You  should set  the time  as the  minute
  5354.           changes.  For that reason, you will not want to use the automatic
  5355.           adjustment capability of CLK  with this type of clock  as it will
  5356.           try to set the time to the nearest second.
  5357.  
  5358.  
  5359.           B.11 Type A - AT&T 6300, 6300 PLUS, 6300 WGS
  5360.  
  5361.           Automatic probing  is accomplished by  trying to read  the clock.
  5362.           If the read attempt  using the BIOS is successful (carry flag not
  5363.           set) and the values returned look like a valid time, the clock is
  5364.           assumed to be present.
  5365.  
  5366.           NOTE:   AT&T clocks do not advance the  year on January 1.  It is
  5367.           necessary to  change  the date  at the  beginning  of each  year.
  5368.  
  5369.           Also, AT&T clocks always clear the  seconds to zero when the time
  5370.           is changed.  For  this reason you should always set  the date and
  5371.           time at the beginning of a  minute.  You should also not use  the
  5372.           automatic adjustment feature of CLK with these clocks.
  5373.  
  5374.           A base year may  be specified on the DEVICE= line.  If it is not,
  5375.           1992  will be used.   This base  will be good  for all dates from
  5376.           1992-1-1 till 1999-12-31.
  5377.  
  5378.           BIOS functions are used with this clock.
  5379.  
  5380.                Get Date: MOV  AH,0FEH                                      
  5381.                          INT  1AH
  5382.                               Returns BX =  Days since base, CH = Hours, CL
  5383.                               = Minutes,  DH = Seconds, DL = 100ths of sec-
  5384.                               onds
  5385.  
  5386.                Set Date: MOV  AH,0FFH                                      
  5387.                          MOV  BX,Days since base
  5388.                          MOV  CH,Hours
  5389.                          MOV  CL,Minutes
  5390.                          MOV  DH,0
  5391.                          MOV  DL,0
  5392.                          INT  1AH
  5393.  
  5394.  
  5395.  
  5396.  
  5397.  
  5398.  
  5399.  
  5400.  
  5401.  
  5402.  
  5403.                                           80
  5404.  
  5405.  
  5406.  
  5407.  
  5408.  
  5409.  
  5410.  
  5411.  
  5412.  
  5413.  
  5414.  
  5415.  
  5416.           CLOCK Version 3.31                               February 4, 1993
  5417.  
  5418.  
  5419.           B.12 Type B - Hyundai 8088 clock
  5420.  
  5421.           Automatic determination probes  the control registers.   If they,
  5422.           appear to be present, CLOCK tries to read  the clock.  Legal time
  5423.           and date values will select this clock.
  5424.  
  5425.           This clock uses I/O addresses E0H through EFH as follows:
  5426.                E0  =  Units digit of seconds
  5427.                E1  =  Tens digit of seconds                                
  5428.                E2  =  Units digit of minutes
  5429.                E3  =  Tens digit of minutes
  5430.                E4  =  Units digit of hours
  5431.                E5  =  Tens digit of hours
  5432.                E6  =  Day of week
  5433.                E7  =  Units digit of days                                  
  5434.                E8  =  Tens digit of days
  5435.                E9  =  Units digit of month
  5436.                EA  =  Tens digit of month
  5437.                EB  =  Units digit of year
  5438.                EC  =  Tens digit of year
  5439.                ED  =  Control                                              
  5440.                EE  =  Control
  5441.                EF  =  Control
  5442.  
  5443.  
  5444.  
  5445.  
  5446.  
  5447.  
  5448.  
  5449.  
  5450.  
  5451.  
  5452.  
  5453.  
  5454.  
  5455.  
  5456.  
  5457.  
  5458.  
  5459.  
  5460.  
  5461.  
  5462.  
  5463.  
  5464.  
  5465.  
  5466.  
  5467.  
  5468.  
  5469.                                           81
  5470.  
  5471.  
  5472.  
  5473.  
  5474.  
  5475.  
  5476.  
  5477.  
  5478.  
  5479.  
  5480.  
  5481.  
  5482.           CLOCK Version 3.31                               February 4, 1993
  5483.  
  5484.  
  5485.           APPENDIX C:  REVISION HISTORY
  5486.  
  5487.           930204 -  Version 3.31: Fixed bug in CLOCK.SYS with binary clocks.
  5488.  
  5489.           930130 -  Version 3.30:  Added  support for  a  password and  for
  5490.                     saving  the current  CLOCK.SYS state as  a new  copy of
  5491.                     CLOCK.SYS  for future booting.   Added  continuous time
  5492.                     display.   Changed  API to  support  direct calls  from
  5493.                     BASIC,  FORTRAN,  and Pascal  as  well as  C  and MASM.
  5494.                     Changed status display to be easier to read.
  5495.  
  5496.  
  5497.           930115 -  Version 3.24: Converted document to WordPerfect 5.1 and
  5498.                     rewrote much  of  it.   Provide  document  in  standard
  5499.                     release that can either be viewed on-line or printed.
  5500.  
  5501.           930110 -  Version 3.23:  Added support  for R=  and W=  commands.
  5502.                     Fixed handling of CLK.INI file  so that we don't try to
  5503.                     update  it  if it  is read  only or  is in  a read-only
  5504.                     sub-directory.   We also  don't update  it if  we can't
  5505.                     find  the [clk]  section as  it may  be someone  else's
  5506.                     file.
  5507.  
  5508.  
  5509.           930106 -  Version  3.22: Fixed bug  in CLK.EXE that  caused it to
  5510.                     move the CLK.INI file to the root directory.
  5511.  
  5512.           930104 -  Version 3.21: Fixed bug in CLOCK.SYS expecting zero for
  5513.                     100ths of seconds from CMOS clock  but some BIOSs don't
  5514.                     zero the register.  Fixed  bug in CLK with synchroniza-
  5515.                     tion algorithm not correctly waiting for a new second.
  5516.  
  5517.           930102 -  Version 3.20:  Add support for a command file, automat-
  5518.                     ic adjustment, and improved synchronization.  My thanks
  5519.                     to Eric Smith for the ideas that lead to these enhance-
  5520.                     ments.
  5521.  
  5522.  
  5523.           921230 -  Version 3.11:  Simplified logic in CLOCK.SYS for check-
  5524.                     ing if calendar clock should be read.
  5525.  
  5526.           921229 -  Version  3.10: Add support for constant synchronization
  5527.                     with calendar clock.  Fix bug in calculating dates near
  5528.                     the end of leap years.
  5529.  
  5530.  
  5531.  
  5532.  
  5533.  
  5534.  
  5535.                                           82
  5536.  
  5537.  
  5538.  
  5539.  
  5540.  
  5541.  
  5542.  
  5543.  
  5544.  
  5545.  
  5546.  
  5547.  
  5548.           CLOCK Version 3.31                               February 4, 1993
  5549.  
  5550.  
  5551.           921226 -  Version 3.02: Recompile CLK.EXE and CLKDEMO.EXE to only
  5552.                     use 8088 instructions.  Version 3.01 inadvertently com-
  5553.                     piled with 80286  instructions which  can lock up  8088
  5554.                     systems.
  5555.  
  5556.           921221 -  Version  3.01: Fixed  a  couple of  bugs  in beta  test
  5557.                     version 3.00 with non-PC/AT clocks.  Added logic to CLK
  5558.                     to  display  the pre-defined  time zones  on  errors or
  5559.                     request.
  5560.  
  5561.  
  5562.           921219 -  Version 3.00: Added support for automatic time zone and
  5563.                     daylight savings  time adjustment.   CLOCK.SYS  now has
  5564.                     the ability to manage  the DOS real time clock  and the
  5565.                     battery-protected clock separately.  CLK.EXE is used to
  5566.                     convert  a base value in the battery-protected clock to
  5567.                     a correct local time in the DOS clock.
  5568.  
  5569.           920614 -  Version 2.24: Fixed bug in probing of AT&T 6300 clocks.
  5570.                     Some of the  clocks do not set AL  on successful opera-
  5571.                     tion.
  5572.  
  5573.  
  5574.           920604 -  Version  2.23:  Fixed  bug causing  fall  through  into
  5575.                     memory probing when only I/O probing was wanted.
  5576.  
  5577.           920411 -  Version 2.22: Changed order of probing to probe memory-
  5578.                     mapped clocks  last as they are  being spuriously found
  5579.                     on some Tandy systems.
  5580.  
  5581.  
  5582.           920401 -  Version  2.21:  Changed pattern  of I/O address probing
  5583.                     to probe all possible I/O addresses for one type (e.g.,
  5584.                     4) before trying any  for another type.   Try to  avoid
  5585.                     finding the wrong type.   Added the type B clock to the
  5586.                     type 8 probe.
  5587.  
  5588.  
  5589.           920328 -  Version 2.20:  Changed order of I/O address probing for
  5590.                     clock  types 4,  6,  and 7  to  avoid, where  possible,
  5591.                     accessing  other boards.  Most  commonly used I/O clock
  5592.                     addresses, I hope, are now probed first.
  5593.  
  5594.  
  5595.           920322 -  Version 2.19:  Improved probing for I/O clocks to check
  5596.                     that legal values are found in all the data  registers.
  5597.  
  5598.  
  5599.  
  5600.  
  5601.                                           83
  5602.  
  5603.  
  5604.  
  5605.  
  5606.  
  5607.  
  5608.  
  5609.  
  5610.  
  5611.  
  5612.  
  5613.  
  5614.           CLOCK Version 3.31                               February 4, 1993
  5615.  
  5616.  
  5617.                     Several of  the I/O  clocks use operation  sequences so
  5618.                     much like each  other that it is possible to choose the
  5619.                     wrong one if we  don't actually read the time  and date
  5620.                     and  see if  the values  are legal.   This  approach to
  5621.                     probing may possibly result in not finding a clock that
  5622.                     is present  but that  has been totally  reset.   Such a
  5623.                     clock should  be found  on a  second try  to boot  with
  5624.                     CLOCK.SYS as the counters will have advanced by then.
  5625.  
  5626.  
  5627.           920320 -  Version  2.18:   Added probing  for generic  PC/AT type
  5628.                     clock on systems that don't have the PC/AT signature in
  5629.                     the BIOS.
  5630.  
  5631.           920307 -  Version 2.17:  Added Hyundai 8088 clock.
  5632.  
  5633.  
  5634.           920112 -  Version 2.16:  Added AT&T 6300 clock.
  5635.  
  5636.           920111 -  Version 2.15:  Fixed memory address used by one type of
  5637.                     SMT No-Slot clock.
  5638.  
  5639.           920105 -  Version  2.14:   Added support  for a wider  variety of
  5640.                     memory mapped  clocks including the SMT  (Systems Manu-
  5641.                     facturing Technology) No-Slot clocks.
  5642.  
  5643.           911208 -  Version 2.13:  Add  probing for Vendex Headstart Turbo-
  5644.                     888-XT system and any other  I/O clock at 300H.  Change
  5645.                     I/O clock probing logic to make it less  likely to find
  5646.                     the wrong type by accident.
  5647.  
  5648.           911129 -  Version 2.12:  Fix handling of Quadram clocks (type 9).
  5649.                     They can only set seconds to zero so generate an  error
  5650.                     if anyone tries to set the seconds to any other value.
  5651.  
  5652.  
  5653.           911128 -  Version  2.11:    Fix  bug in  handling  clock  type 9,
  5654.                     Quadram clocks that left clock  turned off after opera-
  5655.                     tions.   Also fix bug  in busy determination  for clock
  5656.                     types 4 and  6 that could result in a decision that the
  5657.                     clock was not operational.
  5658.  
  5659.  
  5660.  
  5661.  
  5662.  
  5663.  
  5664.  
  5665.  
  5666.  
  5667.                                           84
  5668.  
  5669.  
  5670.  
  5671.  
  5672.  
  5673.  
  5674.  
  5675.  
  5676.  
  5677.  
  5678.  
  5679.  
  5680.           CLOCK Version 3.31                               February 4, 1993
  5681.  
  5682.  
  5683.           911121 -  Version 2.10:  Add clock types 6  ,7 and 9.  Add type 8
  5684.                     to do specific  probing for the  various I/O bus  clock
  5685.                     types.
  5686.  
  5687.  
  5688.           911109 -  Version  2.05:  Fix  bug in  leap day handling  for I/O
  5689.                     clocks.  Fix bug that caused hung systems  when setting
  5690.                     the date or time on Z-18x portables.
  5691.  
  5692.           911026 -  Version 2.04:  Add support  for I/O clocks at addresses
  5693.                     240H  and 340H.    Reduce resident  memory required  by
  5694.                     clock driver to  only that required for  specific clock
  5695.                     type.
  5696.  
  5697.           911021 -  Version  2.03:   Change handling of  new day  flag from
  5698.                     BIOS to  accommodate BIOSs that indicate  multiple days
  5699.                     have passed.
  5700.  
  5701.           911020 -  Version  2.02:  Fix bug in returning date on clock read
  5702.                     functions.  Added message in automatic determination to
  5703.                     indicate type found.
  5704.  
  5705.  
  5706.           911010  - Version   2.01:    Added   automatic  determination  of
  5707.                     Mitsubishi 8088  PC clocks.  Fixed handler  to keep the
  5708.                     BIOS  counter set  properly for  programs that  read it
  5709.                     directly.   Also  returns  a  finer  granularity  value
  5710.                     (100ths of seconds) on reads.
  5711.  
  5712.  
  5713.           911009  - Version 2.00:  Modified  clock driver to support  addi-
  5714.                     tional clock types.  Thanks to Eric Smith (no relation)
  5715.                     for help in finding out how the Zenith PC clock worked.
  5716.  
  5717.           911005  - Version 1.20:  Changed prologue and epilogue to conform
  5718.                     to DOS 5.00 documentation.   Seems to work OK  with DOS
  5719.                     5.0 without  the changes, but we might  as well be con-
  5720.                     sistent to save problems later.
  5721.  
  5722.           910903  - Version 1.10:   Added display of current  date and time
  5723.                     when initializing.
  5724.  
  5725.  
  5726.  
  5727.  
  5728.  
  5729.  
  5730.  
  5731.  
  5732.  
  5733.                                           85
  5734.  
  5735.  
  5736.  
  5737.  
  5738.  
  5739.  
  5740.  
  5741.  
  5742.  
  5743.  
  5744.  
  5745.  
  5746.           CLOCK Version 3.31                               February 4, 1993
  5747.  
  5748.  
  5749.           910518  - CLOCK version  1.00.  Initial version  developed at the
  5750.                     request  of a friend with a  Sperry PC/HT who wanted to
  5751.                     move to DOS 4.01.
  5752.  
  5753.  
  5754.           1984    - Write clock  device driver for AST clock  for IBM PC-1.
  5755.                     This serves as the introduction to what device  drivers
  5756.                     and especially the CLOCK$ driver are all about.
  5757.  
  5758.  
  5759.  
  5760.  
  5761.  
  5762.  
  5763.  
  5764.  
  5765.  
  5766.  
  5767.  
  5768.  
  5769.  
  5770.  
  5771.  
  5772.  
  5773.  
  5774.  
  5775.  
  5776.  
  5777.  
  5778.  
  5779.  
  5780.  
  5781.  
  5782.  
  5783.  
  5784.  
  5785.  
  5786.  
  5787.  
  5788.  
  5789.  
  5790.  
  5791.  
  5792.  
  5793.  
  5794.  
  5795.  
  5796.  
  5797.  
  5798.  
  5799.                                           86
  5800.  
  5801.  
  5802.  
  5803.  
  5804.  
  5805.